Randomly Shuffled XSD Scheme

I am trying to create an XSD scheme that allows elements to be in random order and has maxOccurs = "unbounded".

My XML:

<root>
  <key></key>
  <group></group>
  <group>
     <key></key> 
     <key></key>
     <group>
        <key></key> 
        <key></key>
     </group>
  </group> 
  <key></key>
  <key></key> 
  <group>
     <key></key> 
     <key></key>
     <key></key>
  </group>
  <key></key>
</root>
+5
source share
1 answer

Do you want <xs:choice>:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:complexType name="groupType">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
         <xs:element name="group" type="groupType"/>
         <xs:element name="key"/>
      </xs:choice>
   </xs:complexType>

   <xs:element name="root" type="groupType" />
</xs:schema>

I got this by pasting the XML sample into the Oxygen XML editor and using "Tools> Generate / Convert Schema", with input = your sample XML document. (He can use Trang under covers ... I'm not sure.) Then I changed the result.

+5
source

All Articles