XPath query fails when "as" is a part of a path
XPath query:
/a/b/as
throws an error:
{
- results: [ ],
- total: 0,
- success: false,
- time: 0,
- errorMessage: "Encountered "as" at line 1, column 16. Was expecting one of: <IntegerLiteral> ... <DecimalLiteral> ... <DoubleLiteral> ... <StringLiteral> ... "<?" ... "<?" ... <AxisChild> ... <AxisDescendant> ... <AxisParent> ... <AxisAttribute> ... <AxisSelf> ... <AxisDescendantOrSelf> ... <AxisAncestor> ... <AxisFollowingSibling> ... <AxisPrecedingSibling> ... <AxisFollowing> ... <AxisPreceding> ... <AxisAncestorOrSelf> ... "$" ... <ElementType> ... <AttributeType> ... <SchemaElementType> ... <SchemaAttributeType> ... <OrderedOpen> ... <UnorderedOpen> ... <ElementQNameLbrace> ... <AttributeQNameLbrace> ... <PINCNameLbrace> ... <PILbrace> ... <CommentLbrace> ... <ElementLbrace> ... <AttributeLbrace> ... <TextLbrace> ... "*" ... <NCNameColonStar> ... <StarColonNCName> ... "(" ... "@" ... <DocumentLpar> ... <DocumentLparForKindTest> ... <DocumentLbrace> ... <NodeLpar> ... <CommentLpar> ... <TextLpar> ... <ProcessingInstructionLpar> ... <ElementTypeForKindTest> ... <ElementTypeForDocumentTest> ... <AttributeTypeForKindTest> ... <SchemaElementTypeForKindTest> ... <SchemaElementTypeForDocumentTest> ... <SchemaAttributeTypeForKindTest> ... <ProcessingInstructionLparForKindTest> ... <TextLparForKindTest> ... <CommentLparForKindTest> ... <NodeLparForKindTest> ... "." ... ".." ... <QNameLpar> ... "<" ... "<" ... "<!--" ... "<!--" ... <QName> ... for statement: for $v in /a/b/as return $v"
}
If I understood correctly a XPath parser treats "as" as a reserved word. In jackrabbit code I found this:
statement = "for $v in " + statement + " return $v"; // get parser XPath parser; synchronized (parsers) { parser = (XPath) parsers.get(resolver); if (parser == null) { parser = new XPath(new StringReader(statement)); parsers.put(resolver, parser); } }In linux I've tried to execute the same XPath code using xmllint and it works:
$ xmllint --xpath '/a/b/as' test.html <as> as content </as>
Any ideas what's wrong with jackrabbit when "as" is part of a path?
Thanks