StellaMaris
StellaMaris

Reputation: 867

Saxon cant compile xPath

I build saxon9-7-0-4source.zip and try to execute the xPath .//item[@name='entry']//property[matches(@value,'test[0-9]{1,2}$')]/.. at a dom4j document based on the following xml:

<root>
<item name="abc">
  <iitem>
    <property value="test"/>
  </iitem>
</item>
<item name="entry">
  <iitem>
    <property value="test"/>
  </iitem>
  <iitem>
    <iiitem>
      <property value="test12"/>
    </iiitem>
  </iitem>
  <iitem>
    <property value="123"/>
  </iitem>
</item>
</root>

The xPath does what I exspect, I test it online at http://www.qutoric.com/xslt/analyser/xpathtool.html

But if I try the same in my java code

        Processor proc = new Processor(false);
        proc.getUnderlyingConfiguration().registerExternalObjectModel(new DOM4JObjectModel());
        DocumentBuilder db = proc.newDocumentBuilder();
        XdmNode xdmDoc = db.wrap(doc4j);
        XPathCompiler xpath = proc.newXPathCompiler();
        String path=".//item[@name='entry']//property[matches(@value,'test[0-9]{1,2}$')]/..";
        XPathExecutable viewPath = xpath.compile(path);

I get an unexpected error Exception in thread "main"

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    Cannot instantiate the type SystemFunctionCall

    at net.sf.saxon.functions.SystemFunction.makeFunctionCall(SystemFunction.java:94)
    at net.sf.saxon.functions.RegexFunction.makeFunctionCall(RegexFunction.java:69)
    at net.sf.saxon.functions.RegexFunctionSansFlags.makeFunctionCall(RegexFunctionSansFlags.java:49)
    at net.sf.saxon.functions.SystemFunctionLibrary.bind(SystemFunctionLibrary.java:91)
    at net.sf.saxon.functions.FunctionLibraryList.bind(FunctionLibraryList.java:105)
    at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(XPathParser.java:3015)
    at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(XPathParser.java:2005)
    at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(XPathParser.java:1890)
    at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(XPathParser.java:1815)
    at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(XPathParser.java:1777)
    at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(XPathParser.java:1791)
    at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(XPathParser.java:1666)
    at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(XPathParser.java:653)
    at net.sf.saxon.expr.parser.XPathParser.parseExpression(XPathParser.java:592)
    at net.sf.saxon.expr.parser.XPathParser.parsePredicate(XPathParser.java:1958)
    at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(XPathParser.java:1900)
    at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(XPathParser.java:1820)
    at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(XPathParser.java:1777)
    at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(XPathParser.java:1791)
    at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(XPathParser.java:1666)
    at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(XPathParser.java:653)
    at net.sf.saxon.expr.parser.XPathParser.parseExpression(XPathParser.java:592)
    at net.sf.saxon.expr.parser.XPathParser.parse(XPathParser.java:464)
    at net.sf.saxon.expr.parser.ExpressionTool.make(ExpressionTool.java:98)
    at net.sf.saxon.sxpath.XPathEvaluator.createExpression(XPathEvaluator.java:144)
    at net.sf.saxon.s9api.XPathCompiler.internalCompile(XPathCompiler.java:506)
    at net.sf.saxon.s9api.XPathCompiler.compile(XPathCompiler.java:481)
    at xslt.XSLT.main(XSLT.java:35)

This error occurs if I try to compile the xPath via XPathExecutable viewPath = xpath.compile(path);.

Upvotes: 1

Views: 348

Answers (1)

StellaMaris
StellaMaris

Reputation: 867

I figured out the reason where this Exception comes from. My version of eclipse is to old like it is described here. I have to compile saxon 9.7 against java 8.

Upvotes: 0

Related Questions