XSD for XML's with list of different and reorder types

后端 未结 1 1466
天涯浪人
天涯浪人 2021-01-28 02:22

Tell me please, how can I create xsd schema, which successfully validate the following xml:
Valid XML 1

    

        
相关标签:
1条回答
  • 2021-01-28 02:58

    Try this, it works:

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="start">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="list" type="list"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:complexType name="list">
        <xs:sequence>
          <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="typeA" type="generic" />
            <xs:element name="typeB" type="generic" />
            <xs:element name="typeC" type="generic" />
          </xs:choice>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="generic">
        <xs:sequence>
          <xs:element name="value" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    
    0 讨论(0)
提交回复
热议问题