XQTY0086

If you set the copy-namespaces mode to no-preserve, and the construction mode to preserve, there may be a conflict if your element content (or attribute values) contains namespace-sensitive values, such as qualified names. Namespaces used in content (as opposed to in element/attribute names) are not considered to be "used."

For example, suppose your input document (qnames.xml) looks like this:

<listOfQualifiedNames xmlns:prod="http://datypic.com/prod">
 <qName>prod:xyz</qName>
 <qName>prod:abc</qName>
</listOfQualifiedNames>

Suppose also that this document has been validated with a schema, and the qName elements are annotated with the type xs:QName. You might query the document with:

<myNewList>{doc("qnames.xml")//qName}</myNewList>

intending to return a new element that contains the two qName elements. If construction mode is preserve, the qName elements will still have the type xs:QName. But if the copy-namespaces mode is no-preserve, the http://datypic.com/prod namespace will not be preserved, because it is used only in content, not in element or attribute names. Therefore, the qName elements' content will have undefined prefixes and this error will be raised.

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.