Talk:XQuery/XML Schema to Instance
Add topicAppearance
Latest comment: 9 years ago by Keeleleek
Concerning the last item in your TO-DO list: - Handle any xsd file prefix (e.g. xs:element or xsd:element)
There is actually no need for handling the prefix if you just declare a namespace for XML Schema. If there is a namespace declared, paths are matched against the identity of the namespace instead of the prefix. The prefix 'xs' is always predeclared in XQuery.
So in the following example, the prefix 'foo' will match all elements that the predeclared 'xs' prefix would do:
xquery version "1.0";
declare namespace foo = 'http://www.w3.org/2001/XMLSchema';
count(doc('schema.xsd')/foo:schema)
(: the count should be equal to 1 :)