开发者

is there a way to link equal type definitions together?

example code:

<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开发者_Go百科: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>

Now the type definition of element a and b are the same. is there a way to "link" those types together so that i do not have to repeat the typing?


Ok, I see. The easiest way to go is to create a named type:

<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" />

where tns is a prefix for your schema target namespace

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜