1
我想看看使用類型來選擇子類型的元素,所以我有一個測試文檔與xs:integer和xs:float的子類型。如何設置架構感知XQuery
如何讓XQuery使用我的模式中定義的類型?
(這可能是相關的,我使用的氧氣和撒克遜-SA)
輸入文檔:
<?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模式:
<?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>