简体   繁体   中英

XSD schema: restriction on attribute inherited by another element

I have a problem with my XSD schema. I have an element called which have an attribute id of type xsd:string and it must have no restrictions. Then there's another element which extends and has several more attributes BUT the inherited attribute "id" has to be composed by letters and digits only. Here is my code:

I've tried to add both and to and give id attribute a new type but it doesn't work.

<xsd:complexType name="BaseElement">
    <xsd:attribute name="id" type="xsd:string" />
</xsd:complexType>

<xsd:complexType name="Element">
    <xsd:complexContent>
    <xsd:restriction base="BaseElement">
        <xsd:attribute name="id" type="xsd:idNewType" />
    </xsd:restriction>
    <xsd:extension base="identifiedEntityType">
           <xsd:attribute name="attr2" type="xsd:string"/>
           <xsd:attribute name="attr3" type="xsd:string"/>
          </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>

您不能在一个步骤中定义限制和扩展,但是可以将X定义为Y的限制,并将Y定义为Z的扩展,因此扩展步骤将添加两个属性,然后限制步骤将限制一个其中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM