1
유형을 사용하여 하위 유형 인 요소를 선택하려고합니다. 따라서 하위 유형이 xs : integer 및 xs : float 인 테스트 문서가 있습니다.스키마 인식 XQuery를 설정하는 방법
내 스키마에 정의 된 유형을 사용하도록 XQuery에 지시하려면 어떻게해야합니까?
<?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>
입력 문서 (내가 산소와 색슨-SA를 사용하고 있다는 관련이있을 수 있음)