Examples of XPathExpression


Examples of net.sf.saxon.sxpath.XPathExpression

              path = '.' + path;
            } else {
              path = path.substring(1);
            }
          }
        XPathExpression exp;
      try {
        exp = eval.createExpression(path);
      } catch (XPathException e) {
        throw new QueryResolverException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.invalid_path", xmlColumn.getName(), xmlColumn.getPath())); //$NON-NLS-1$
     
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathExpression

    for (XMLColumn proColumn : projectedColumns) {
      if (proColumn.isOrdinal()) {
        tuple.add(rowCount);
      } else {
        try {
          XPathExpression path = proColumn.getPathExpression();
          XPathDynamicContext dynamicContext = path.createDynamicContext(item);
          SequenceIterator pathIter = path.iterate(dynamicContext);
          Item colItem = pathIter.next();
          if (colItem == null) {
            if (proColumn.getDefaultExpression() != null) {
              tuple.add(getEvaluator(Collections.emptyMap()).evaluate(proColumn.getDefaultExpression(), null));
            } else {
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathExpression

                sc.declareNamespace((String) entry.getKey(),
                        (String) entry.getValue());
            }
            xpe.setStaticContext(sc);
            XPathVariable thisVar = xpe.declareVariable("", contextVar);
            XPathExpression xpath = xpe.createExpression(path);
            NodeInfo contextItem =
                //config.buildDocument(new DOMSource(contextNode));
                config.unravel(new DOMSource(contextNode));
            XPathDynamicContext dc = xpath.createDynamicContext(null);
            dc.setContextItem(contextItem);
            dc.setVariable(thisVar, contextItem);

            List saxonNodes = xpath.evaluate(dc);
            for (ListIterator it = saxonNodes.listIterator(); it.hasNext(); )
            {
                Object o = it.next();
                if (o instanceof NodeInfo)
                {
View Full Code Here

Examples of net.sf.saxon.xpath.XPathExpression

        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
                boolean found = false;
                for (Iterator iter = matchedLines.iterator(); iter.hasNext();) {

                    // Note that we have found at least one line
                    found = true;

                    // Get the next matching line
                    NodeInfo line = (NodeInfo)iter.next();

                    // Find where it appears in the play
                    findLocation.setContextNode(line);
                    System.out.println("\n" + findLocation.evaluateSingle());

                    // Find out who the speaker of this line is
                    findSpeaker.setContextNode(line);

                    // Output the name of the speaker and the content of the line
                    System.out.println(findSpeaker.evaluateSingle() + ":  " + line.getStringValue());
                }

                // If no lines were found, say so
                if (!found) {
                    System.err.println("No lines were found containing the word '" + word + "'");
View Full Code Here

Examples of org.apache.camel.model.language.XPathExpression

     * @param text       the expression to be evaluated
     * @param resultType the return type expected by the expressiopn
     * @return the builder to continue processing the DSL
     */
    public T xpath(String text, Class resultType) {
        XPathExpression expression = new XPathExpression(text);
        expression.setResultType(resultType);
        setExpressionType(expression);
        return result;
    }
View Full Code Here

Examples of org.apache.camel.model.language.XPathExpression

     * @param resultType the return type expected by the expression
     * @param namespaces the namespace prefix and URIs to use
     * @return the builder to continue processing the DSL
     */
    public T xpath(String text, Class resultType, Map<String, String> namespaces) {
        XPathExpression expression = new XPathExpression(text);
        expression.setResultType(resultType);
        expression.setNamespaces(namespaces);
        setExpressionType(expression);
        return result;
    }
View Full Code Here

Examples of org.apache.camel.model.language.XPathExpression

     * @param text       the expression to be evaluated
     * @param namespaces the namespace prefix and URIs to use
     * @return the builder to continue processing the DSL
     */
    public T xpath(String text, Map<String, String> namespaces) {
        XPathExpression expression = new XPathExpression(text);
        expression.setNamespaces(namespaces);
        setExpressionType(expression);
        return result;
    }
View Full Code Here

Examples of org.apache.camel.model.language.XPathExpression

    /**
     * Creates the XPath expression using the current namespace context
     */
    public XPathExpression xpath(String expression) {
        XPathExpression answer = new XPathExpression(expression);
        configure(answer);
        return answer;
    }
View Full Code Here

Examples of org.apache.camel.model.language.XPathExpression

    /**
     * Creates the XPath expression using the current namespace context
     */
    public XPathExpression xpath(String expression, Class<?> resultType) {
        XPathExpression answer = xpath(expression);
        answer.setResultType(resultType);
        return answer;
    }
View Full Code Here

Examples of org.apache.commons.jelly.expression.xpath.XPathExpression

            Expression xpathExpr = super.createExpression( factory,
                                                           tagScript,
                                                           attributeName,
                                                           attributeValue );

            return new XPathExpression(attributeValue, xpathExpr, tagScript);
        }

        // will use the default expression instead
        return super.createExpression(factory, tagScript, attributeName, attributeValue);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.