Digital humanities

Maintained by: David J. Birnbaum ( [Creative Commons BY-NC-SA 3.0 Unported License] Last modified: 2019-04-19T16:54:01+0000

Test #8: XQuery

The task

Basic requirements

For this test, you'll be using the version of Hamlet available on eXist. You can access this document using doc('/db/apps/shakespeare/data/ham.xml').

Your goal is to create valid XHTML output, which puts the following information into a table:

The first three lines of our output looks like this:

Act and scene Number of speeches Number of lines Speakers
Act 1, Scene 1 60 190 Bernardo, Francisco, Horatio, Marcellus
Act 1, Scene 2 75 275 All, Cornelius and Voltimand, Gertrude, Hamlet, Horatio, King, Laertes, Marcellus, Marcellus and Bernardo, Polonius


  1. In situations where some speakers speak both alone and with others, as is the case with Marcellus and Marcellus and Bernardo in Act 1, Scene 2, above, you may include both their solo and their combined appearances as if they were separate speakers, as we do above. You are not responsible for removing overlap of this sort.
  2. If you tell eXide to render the output as direct output, the result will look like an HTML table, but without borders or other CSS styling. For the purpose of this exercise that’s fine; you are not responsible for borders or other styling.
  3. In Real Life HTML output should be in the HTML namespace, but we haven’t talked about how to do that when generating XQuery inside eXide, so for the purpose of this activity you may ignore that output expectation.