Shakespeare Demo Application

down arrow Code & Downloads

The Shakespeare demo application allows you to search across all of the Shakespeare plays and display the plays scene-by-scene. It includes a master table of contents, a search page allowing simple searches with 'and' boolean logic, and an advanced search page which adds near searches to the search options. In any search, you can enter double-quotes around a phrase to indicate a phrase search (for example, "to be or not to be" will return a single hit from Hamlet).

The application is written in XQuery, with some javascript to help with the table of contents tree control. The XQuery code sends xhtml pages to display on the browser. It is intended as a simple sample of an application you can write in MarkLogic Server, and demonstrates some common design patterns used in MarkLogic applications. It includes all of the code for the application. Feel free to play around and modify the code to suit your needs and to learn how it works.

Some of the features and design patterns of the application include:

  • generating a table of contents from a content set
  • dynamically transforming content from its original XML structure to xhtml (using a recursive typeswitch)
  • full text search, including a search box and a search results page
  • proximity (cts:near-query) search page
  • a simple query parser (parses double-quoted text as phrases)
  • some interesting examples of text highlighting using cts:highlight
  • dynamically counts and displays the line numbers
  • and much more....
  • using properties to store metadata


  • Great Article. it’s Really Helpful and Enjoyable Post for Every Blogger. Thank you very much for Sharing with us!!! <a href="">IT Outsourcing Fort Worth</a>
  • Great Article about Shakespeare. Thank you very much for Sharing with us. I’m sending it to some buddies and also sharing in delicious, i am so happy by visit this site that i am already bookmark this site.i will come back again And certainly, thank you for your sweat! <a href="">traffic geyser pro</a>
  • This is a very good article. I think there will be many people like it, of course, I was one of the people. I think this article increase my knowledge. it is nice to know this. Thanks for the time and effort. <a href=""></a>