Exist: Non-standard behavior in sibling axes

Created on 28 Feb 2017  路  3Comments  路  Source: eXist-db/exist

What is the problem

The axes preceding-sibling and following-sibling should be empty on an attribute nodes. Instead, an array index out of bounds exception is thrown:

let $d := <a b="c"/>
return empty($d/@b/preceding-sibling::*)
### What did you expect `true` should be returned (see https://www.w3.org/TR/xpath/#axes). Instead, the following exception is thrown:
java.lang.ArrayIndexOutOfBoundsException: -1
    at org.exist.dom.memtree.DocumentImpl.getFirstChildFor(DocumentImpl.java:630) ~[exist.jar:?]
    at org.exist.dom.memtree.NodeImpl.selectPrecedingSiblings(NodeImpl.java:787) ~[exist.jar:?]
    at org.exist.xquery.value.ValueSequence.getPrecedingSiblings(ValueSequence.java:630) ~[exist.jar:?]
    at org.exist.xquery.LocationStep.getSiblings(LocationStep.java:875) ~[exist.jar:?]
    at org.exist.xquery.LocationStep.eval(LocationStep.java:450) ~[exist.jar:?]
    at org.exist.xquery.PathExpr.eval(PathExpr.java:269) ~[exist.jar:?]
    at org.exist.xquery.DebuggableExpression.eval(DebuggableExpression.java:58) ~[exist.jar:?]
    at org.exist.xquery.LetExpr.eval(LetExpr.java:111) ~[exist.jar:?]
    at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71) ~[exist.jar:?]
    at org.exist.xquery.PathExpr.eval(PathExpr.java:276) ~[exist.jar:?]
    at org.exist.xquery.AbstractExpression.eval(AbstractExpression.java:71) ~[exist.jar:?]
    at org.exist.xquery.XQuery.execute(XQuery.java:253) ~[exist.jar:?]
    at org.exist.xquery.XQuery.execute(XQuery.java:185) ~[exist.jar:?]
    at org.exist.http.servlets.XQueryServlet.process(XQueryServlet.java:470) [exist-optional.jar:?]
    at org.exist.http.servlets.XQueryServlet.doPost(XQueryServlet.java:191) [exist-optional.jar:?]
...

Describe how to reproduce or add a test

Execute the query in eXide

Context information

  • eXist-db version 3.0 / develop-acd0c14
  • java version "1.8.0_91"
  • MacOs
  • 64 bit
  • No custom changes
bug

Most helpful comment

I can confirm this is a bug and I have been able to produce a fix.

All 3 comments

I can confirm this is a bug and I have been able to produce a fix.

I see in getPrecedingSiblings() :

        // if the context node is an attribute or namespace node, the preceding-sibling axis is empty
        if (node.getNodeType() != Node.ATTRIBUTE_NODE) {

Where is the Namespace node test ?

Same issue for getFollowingSiblings()

@brihaye AFAIK there is no separate Node type for a Namespace Node.

Was this page helpful?
0 / 5 - 0 ratings