我需要完成这样的模式:
<object type="possession">
<property name="VIN">1111111111111111</property>
<property name="Year">2003</property>
<property name="Make">Chevrolet</property>
</object>
- 该“VIN”属性必须是17个字符
- “年物业类型必须为gYear的
- “品牌”属性必须符合{福特,雪佛兰,马自达}的枚举
现在,我有这样的:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="object">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="property" maxOccurs="1" minOccurs="0" type="VinType"></xs:element>
<xs:element name="property" maxOccurs="1" minOccurs="0" type="YearType"></xs:element>
<xs:element name="property" maxOccurs="1" minOccurs="0" type="MakeType"></xs:element>
</xs:choice>
<xs:attribute name="type" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<!-- Vehicle Identification number (VIN) -->
<xs:simpleType name="VinRestriction">
<xs:restriction base="xs:string">
<xs:length fixed="true" value="17"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="VinType" mixed="true">
<xs:simpleContent>
<xs:extension base="VinRestriction">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="VIN" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Vehicle Year -->
<xs:simpleType name="YearRestriction">
<xs:restriction base="xs:gYear"/>
</xs:simpleType>
<xs:complexType name="YearType" mixed="true">
<xs:simpleContent>
<xs:extension base="YearRestriction">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="Year" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Vehicle Make -->
<xs:simpleType name="MakeRestriction">
<xs:restriction base="xs:string">
<xs:enumeration value="Chevrolet"/>
<xs:enumeration value="Ford"/>
<xs:enumeration value="Mazda"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="MakeType" mixed="true">
<xs:simpleContent>
<xs:extension base="MakeRestriction">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="Make" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>