Есть ли способ связать определения одинакового типа вместе? - PullRequest
0 голосов
/ 18 августа 2011

пример кода:

<xsd:element name="a">
    <xsd:simpleType>
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="|(([1-9]|[12][0-9]|3[01])/([0-9]|1[12])/[0-9]{1,4})"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:element>
<xsd:element name="b">
    <xsd:simpleType>
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="|(([1-9]|[12][0-9]|3[01])/([0-9]|1[12])/[0-9]{1,4})"/>
        </xsd:restriction>
    </xsd:simpleType>
</xsd:element>

Теперь определения типов элементов a и b совпадают. Есть ли способ "связать" эти типы вместе, чтобы мне не пришлось повторять ввод?

1 Ответ

1 голос
/ 18 августа 2011

Хорошо, я вижу.Самый простой способ - создать именованный тип:

<xsd:simpleType name="PatternType">
    <xsd:restriction base="xsd:string">
        <xsd:pattern value="|(([1-9]|[12][0-9]|3[01])/([0-9]|1[12])/[0-9]{1,4})" />
    </xsd:restriction>
</xsd:simpleType>

<xsd:element name="a" type="tns:PatternType" />
<xsd:element name="b" type="tns:PatternType" />

, где tns - префикс для пространства имен целевого объекта схемы

...