简体   繁体   中英

Add a restriction to a complexType element in XSD

Given the following element:

  <xsd:element name="abr">
    <xsd:annotation>
      <xsd:documentation>Abbreviaturen</xsd:documentation>
    </xsd:annotation>
    <xsd:complexType mixed="true">
      <xsd:choice maxOccurs="unbounded" minOccurs="0">
        <xsd:element ref="maj"/>
        <xsd:element ref="sup"/>
        <xsd:element ref="lin"/>
        <xsd:element ref="cap"/>
        <xsd:element ref="cif"/>
      </xsd:choice>
    </xsd:complexType>
  </xsd:element>

I want to add the following restriction to the tag <abr> content (deny spaces):

  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[^\r\n\t ]*"/>
  </xsd:restriction>

How can I define this restriction in order to be valid ?

The element has a mixed content model (allowing child elements as well as text). There is no mechanism in XSD 1.0 to restrict what can appear in the text nodes within an element with mixed content. You can do it in XSD 1.1 with assertions.

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