<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="samples" page="shakespeare" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Shakespeare Example</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Shakespeare Example"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Shakespeare Example</h1>
      <p>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 <a href="http://www.ibiblio.org/bosak/xml/eg/shaks200.zip" class="bodylink">http://www.ibiblio.org/bosak/xml/eg/shaks200.zip</a>,
but for convenience one of them, <i>Othello</i>, is included in the Saxon distribution
(in the samples\data directory).</p>
      <p class="subhead">Shakespeare stylesheet</p>
      <p>There is an XSLT stylesheet, <code>play.xsl</code>, 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 on the Java platform, create a directory (say playhtml) and execute the following
from the command line:</p>
      <p class="command">
cd samples<br/>
java net.sf.saxon.Transform data\othello.xml styles\play.xsl dir=playhtml
</p>
      <p>The equivalent on .NET is:</p>
      <p class="command">
cd samples<br/>
Transform data\othello.xml styles\play.xsl dir=playhtml
</p>
      <p>The last parameter sets the value of the constant <b>dir</b> to the value <b>playhtml</b>;
this constant is referenced from the style sheet when creating output files.</p>
      <p class="subhead">Shakespeare XPath Sample Application</p>
      <p><i>This example applies to the Java platform only. However, there is also a C# version of this
application in <code>samples/cs/XPathExample</code>.</i></p>
      <p>In the <code>samples/java</code> directory is an example application called
<code>XPathExample.java</code>. 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.</p>
      <p>To run this example, first ensure that it is on your classpath, and find the location of
the <code>othello.xml</code> file in the <code>samples/data</code> directory. Open a command-line
console, and run the application using the command:</p>
      <p class="command">
cd samples<br/>
java XPathExample data\othello.xml
</p>
      <p>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 ".".</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="bible.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>