我希望能夠對我的XML文件進行版本控制。我想要一個較舊的xsd文件能夠驗證接收到的XML文件的較新版本。帶有跳過行爲屬性的版本控制的XSD
爲此,我將使用版本屬性來保護未知的xml標籤。
問題:如何根據版本屬性讓xsd跳過XML的一部分?在下面的例子中我想的XSD能夠驗證任何標籤與版本1和2,但不是3
場景:
<MYXML>
<SOME_XML version="1">
<SOME_VERSION_1_DATA>this_is_data_only_for_version_1</SOME_VERSION_1_DATA>
</SOME_XML>
<SOME_XML version="2">
<SOME_VERSION_2_DATA>this_is_data_only_for_version_2</SOME_VERSION_2_DATA>
</SOME_XML>
<SOME_XML version="3">
<SOME_VERSION_3_DATA>this_is_data_only_for_version_3</SOME_VERSION_3_DATA>
</SOME_XML>
</MYXML>
<xs:complexType name="SOME_XML">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="SOME_VERSION_1_DATA" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="SOME_VERSION_2_DATA" type="xs:string"/>
</xs:sequence>
<xs:attribute ref="version"/>
</xs:complexType>
<xs:attribute name="version">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
<xs:anyAttribute processContents="skip"/> <-- SKIP the attribute if NOT 1 ro 2?
</xs:simpleType>
</xs:attribute>