I'm trying to look at using types to select elements that are subtypes, so I have a test document with subtypes of xs:integer and xs:float.
How do I tell XQuery to use the types defined in my schema?
(It might be relevant that I'm using oXygen and Saxon-SA)
Input document:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test-inherit.xsd">
<int>4</int>
<rest-int>5</rest-int>
<rest-float>6</rest-float>
</root>
WXS Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="int" type="xs:integer"/>
<xs:element name="rest-int" type="rest-int"/>
<xs:element name="rest-float" type="rest-float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="rest-int">
<xs:restriction base="xs:integer">
<xs:maxInclusive value="10"></xs:maxInclusive>
<xs:minInclusive value="0"></xs:minInclusive>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="rest-float">
<xs:restriction base="xs:float">
<xs:maxInclusive value="10"></xs:maxInclusive>
<xs:minInclusive value="0"></xs:minInclusive>
</xs:restriction>
</xs:simpleType>
</xs:schema>
XQuery:
for $integer in doc("test-inherit.xml")//element(xs:integer)
return <integer>{$integer}</integer>