Package net.sf.saxon.xpath

Examples of net.sf.saxon.xpath.Variable


        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));

        // Loop until the user enters "." to end the application

        while (true) {

            // Prompt for input
            System.out.println("\n>>>> Enter a word to search for, or '.' to quit:\n");

            // Read the input
            String word = in.readLine().trim();
            if (word.equals(".")) {
                break;
            }
            if (!word.equals("")) {

                // Set the value of the XPath variable
                wordVar.setValue(word);

                // Find the lines containing the requested word
                List matchedLines = findLine.evaluate();

                // Process these lines
View Full Code Here

TOP

Related Classes of net.sf.saxon.xpath.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.