XSD file for validating XML data

Can anyone help me create an XSD file for validating XML like files:

[test]
[a/]
[b/]
[a/]
[b/]
[/test]

[test]
[a/]
[a/]
[b/]
[/test]

      

Basically, I can have any number of nodes <a>

and / or <b>

without any other rule (can't use <xs:sequence>

).

+1


source to share


2 answers


This is not very fast if you have many a or b nodes , but it is confirmed by what you described.



<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="test">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="a"/>
          <xs:element name="b"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

      

+1


source


If you are pasting the XML sample, we can help you better. However, Microsoft has an XSD code generator that generates an XSD based on the XML file that you pass as an argument.



0


source







All Articles