// Create an XPathEvaluator and set the source document
InputSource is = new InputSource(new File(filename).toURL().toString());
SAXSource ss = new SAXSource(is);
XPathEvaluator xpe = new XPathEvaluator(ss);
// Declare a variable for use in XPath expressions
StandaloneContext sc = (StandaloneContext)xpe.getStaticContext();
Variable wordVar = sc.declareVariable("word", "");
// Compile the XPath expressions used by the application
XPathExpression findLine =
xpe.createExpression("//LINE[contains(., $word)]");
XPathExpression findLocation =
xpe.createExpression("concat(ancestor::ACT/TITLE, ' ', ancestor::SCENE/TITLE)");
XPathExpression findSpeaker =
xpe.createExpression("string(ancestor::SPEECH/SPEAKER[1])");
// Create a reader for reading input from the console
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));