Shakespeare example

This example works on an input file containing a Shakespeare play. You can use any of the Shakespeare plays in Jon Bosak's distribution at http://www.ibiblio.org/bosak/xml/eg/shaks200.zip, but for convenience one of them, Othello, is included in the saxon-resources download (in the samples/data directory).

Shakespeare stylesheet

There is an XSLT stylesheet play.xsl which processes an input play in XML and generates a set of linked HTML files (one for the play and one for each scene) in an output directory.

To run this with SaxonJ, create a directory (say playhtml) and execute the following from the command line:

cd samples
java net.sf.saxon.Transform -s:data/othello.xml -xsl:styles/play.xsl dir=playhtml

The equivalent with SaxonCS is:

cd samples
dotnet SaxonCS transform -s:data/othello.xml -xsl:styles/play.xsl dir=playhtml

The last parameter sets the value of the constant dir to the value playhtml; this constant is referenced from the stylesheet when creating output files.

Shakespeare XPath sample application

An example application called XPathExample is provided, for Java only (samples/java/he/XPathExample.java). This is designed to illustrate the use of Saxon's implementation of the JAXP 1.3 XPath API from a Java application. It searches a Shakespeare play for all occurrences of a word entered from the console, displaying the lines containing that word, and the context where they appear.

To run this example, first ensure that it is on your classpath, and find the location of the othello.xml file in the samples/data directory. Open a command-line console, and run the Java application using the command:

cd samples
java he/XPathExample data/othello.xml

The application prompts for a word. Enter the word (try "castle" or "handkerchief"). The lines containing the chosen word are displayed on the console. Exit the application by entering ".".

Other sample applications

Also see the related sample programs XPathExampleDOM.java - a variant of the XPathExample application written to use DOM interfaces, and XPathExampleServlet.java which illustrates the use of the JAXP XPath API within a Java servlet.