Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

XPath problem with Saxon 8-1b

Help
2004-09-30
2012-10-08
  • David Ufton
    David Ufton
    2004-09-30

    I am getting an ArrayIndexOutOfBoundsException when trying to evaluate XPath expressions which contain further XPath expressions inside conditionals. The exception is:

    java.lang.ArrayIndexOutOfBoundsException: 1
    at net.sf.saxon.expr.XPathContextMajor.setLocalVariable(XPathContextMajor.java:213)
    at net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:60)
    at net.sf.saxon.xpath.XPathEvaluator.evaluate(XPathEvaluator.java:183)

    My example XML is:

    <?xml version="1.0" encoding="UTF-8"?>
    <Test>
    <Book id="1">
    <Title>The Two Towers</Title>
    <AuthorRef id="3"/>
    </Book>
    <Book id="2">
    <Title>The Hitchikers Guide to the Galaxy</Title>
    <AuthorRef id="4"/>
    </Book>
    <Author id="3">
    <Name>J.R.R. Tolkien</Name>
    </Author>
    <Author id="4">
    <Name>Douglas Adams</Name>
    </Author>
    </Test>

    examples of XPaths which fail:

    /Test/Author[@id=/Test/Book[1]/AuthorRef/@id]/Name

    /Test/Author[@id=/Test/Book[Title=\&quot;The Two Towers\&quot;]/AuthorRef/@id]/Name

    Apologies for the formatting!