0

I want to change complexType in xsd so that it support disorder elements and multiplely occuers elements.

Let's say, I have xsd and config1 as below, and I also want to support both config1 and config2 without changing config1. (config 1 and 2 differs in some element order(IsEnable and Name).) Is that possible?

I try to replace xs:sequence with xs:all, but elements under xs:all can only occuer exact 0 or 1 time.

//xsd
<xs:element name="Config">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="IsEnabled" type="xs:boolean" minOccurs="1" />
        <xs:element name="Name" type="xs:string" minOccurs="1" />
        <xs:element name="Address" type="xs:string" minOccurs="0" maxOccurs="unbounded">
      </xs:sequence>
    </xs:complexType>
  </xs:element>

//config1
<Congfig>
  <IsEnable>true</IsEnable>
  <Name>name</Name>
  <Address>addr1</Address>
  <Address>addr2</Address>
</Config>

//config2
<Congfig>
  <Name>name</Name>
  <IsEnable>true</IsEnable>
  <Address>addr1</Address>
  <Address>addr2</Address>
</Config>
YutingZuo
  • 15
  • 3

1 Answers1

0

XSD 1.0 doesn't allow you to do this.

You can do it in XSD 1.1.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • xsd 1.0 and 1.1 differ a lot, and I have to modify config1 to upgrade xsd. There is a lot of config like config1 in my project, it takes effort and risk to do it. – YutingZuo May 13 '20 at 14:52
  • It's your choice. Upgrading to new technology always has a cost. It all depends on how badly you need this feature. – Michael Kay May 13 '20 at 15:00