Я пытаюсь написать документ схемы XML в XSD 1.1.В частности, я пытаюсь использовать Type Alternative .
Мой XSD-документ выглядит следующим образом
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
targetNamespace="http://shop.accesso.com"
xmlns="http://shop.accesso.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="CONFIG">
<xs:complexType>
<xs:sequence>
<!-- define an element named 'settings' -->
<xs:element name="settings">
<xs:complexType>
<xs:attribute name="servlet" type="xs:anyURI" use="required"/>
<xs:attribute name="machineId" type="xs:unsignedByte" use="required"/>
<xs:attribute name="merchantId" type="xs:unsignedShort" use="required"/>
<xs:attribute name="language" type="xs:string"/>
<xs:attribute name="locale" type="xs:string"/>
<xs:attribute name="maximize" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<!-- any number of PARAM elements, setting alternative types based on the key attribute value -->
<xs:element name="PARAM" type="baseParamType" maxOccurs="unbounded">
<xs:alternative test="@key='printers'" type="printerParamType"/>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- base PARAM type -->
<xs:complexType name="baseParamType">
<xs:attribute name="key" use="required" type="paramKeyTypes"/>
</xs:complexType>
<!-- Printer PARAM type -->
<xs:complexType name="printerParamType">
<xs:complexContent>
<!-- extend the base PARAM type -->
<xs:extension base="baseParamType">
<!-- the printer PARAM can have a child FORMAT element -->
<xs:sequence>
<xs:element name="FORMAT">
<xs:complexType>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="printer" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Normal PARAM -->
<xs:complexType name="nonPrinterParamType">
<!-- empty for now -->
</xs:complexType>
<!-- valid values for the key attribute of PARAM elements -->
<xs:simpleType name="paramKeyTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="printers"/>
<xs:enumeration value="dynamic_gateway_config"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
А вот конфигурация, которую он проверяет
<?xml version="1.0"?>
<CONFIG xmlns="http://shop.accesso.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://shop.accesso.com config.xsd">
<settings servlet="http://localhost:1813"
machineId="1"
merchantId="803"
language="en"
locale="en_US"
maximize="false" />
<PARAM key="printers">
<FORMAT name="default" printer="Microsoft XPS Document Writer" />
</PARAM>
<PARAM key="use_static_gateway_config" />
</CONFIG>
Однако, это ошибка с дочерним элементом FORMAT PARAM с ключом "printers", говоря, что
Элемент FORMAT здесь не разрешен