XPTY0020

You have specified a relative path expression, but the current context item is not a node. This might occur, for example, if you use a relative path in a predicate where the current context item is an atomic value, as in:

doc("catalog.xml")//product/substring(name,1,3)[@dept = 'ACC']

The path expression @dept is being evaluated relative to the substring of the name (an atomic value) rather than the product element. In this case, the predicate can be moved to the previous step, as in:

doc("catalog.xml")//product[@dept = 'ACC']/substring(name,1,3)

Get XQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.