Package net.sf.saxon.s9api

Examples of net.sf.saxon.s9api.XPathSelector


  private Map<ASTNode, String> findMatches(String xmlDoc, Pattern description,
      XmlVisitor visitor, XdmNode sourceDoc, XPathCompiler xpath)
      throws SaxonApiException {
    Map<ASTNode, String> result = new HashMap<ASTNode, String>();
    String expression = description.xpath;
    XPathSelector selector = compileExpr(xpath, expression);
    selector.setContextItem(sourceDoc);
    XPathSelector outputBeforeSelector = null;
    if (description.outputBefore != null) {
      outputBeforeSelector = outputXPathCompiler.compile(description.outputBefore).load();
    }

    for (XdmItem item : selector) {
      String valueToInsertBefore = null;
      ASTNode node = Utils.getMappedAstNode(visitor, item);
      if (node == null)
        throw new RuntimeException("Found node is not in AST: " + item);
      if (outputBeforeSelector != null) {
        outputBeforeSelector.setContextItem(item);
        outputBeforeSelector.setVariable(CONTEXT_VARIABLE, item);
        valueToInsertBefore = outputBeforeSelector.evaluate().toString();
      }
      result.put(node, valueToInsertBefore);
    }

    return result;
View Full Code Here

TOP

Related Classes of net.sf.saxon.s9api.XPathSelector

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.