Reputation: 13
Can anybody help me to build an XSD file to validate XMLs like these:
[test]
[a/]
[b/]
[a/]
[b/]
[/test]
[test]
[a/]
[a/]
[b/]
[/test]
Basically, I can have any number of <a>
and/or <b>
nodes without any other rule (can't use <xs:sequence>
).
Upvotes: 1
Views: 433
Reputation: 1568
It isn't going to very fast if you have a lot of a or b nodes but this validates against what you've 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>
Upvotes: 1
Reputation: 57907
If you paste the sample XML, we can help you better. However, Microsoft has an XSD code generator that generates an XSD based on an XML file that you pass in as an argument.
Upvotes: 0