Felix Nensa
2010-01-28 17:04:19 UTC
Hi experts,
I have some tricky XML that needs to be validated against an XSD, that I am
not sure how to define.
The XML could come in several variations. Some examples:
Example 1:
<SomeElement>
<A>aaa</A>
<B>bbb</B>
<C>ccc</C>
<D>ddd</D>
<D>dde</D>
</SomeElement>
Example 2:
<SomeElement>
<B>bbb</B>
<A>aaa</A>
<C>ccc</C>
<D>ddd</D>
<D>dde</D>
</SomeElement>
Example 3:
<SomeElement>
<B>bbb</B>
<A>aaa</A>
<D>ddd</D>
<D>dde</D>
</SomeElement>
The corresponding XSD that I would like to define (but of course is invalid)
would look like this:
<xs:element name="SomeElement">
<xs:complexType>
<xs:all>
<xs:element name="A" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="B" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="C" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="D" type="xs:string" minOccurs="1"
maxOccurs="unbounded" />
</xs:all>
</xs:complexType>
</xs:element>
Any ideas how to achive the same with valid XSD?
Thanks in advance,
Felix
I have some tricky XML that needs to be validated against an XSD, that I am
not sure how to define.
The XML could come in several variations. Some examples:
Example 1:
<SomeElement>
<A>aaa</A>
<B>bbb</B>
<C>ccc</C>
<D>ddd</D>
<D>dde</D>
</SomeElement>
Example 2:
<SomeElement>
<B>bbb</B>
<A>aaa</A>
<C>ccc</C>
<D>ddd</D>
<D>dde</D>
</SomeElement>
Example 3:
<SomeElement>
<B>bbb</B>
<A>aaa</A>
<D>ddd</D>
<D>dde</D>
</SomeElement>
The corresponding XSD that I would like to define (but of course is invalid)
would look like this:
<xs:element name="SomeElement">
<xs:complexType>
<xs:all>
<xs:element name="A" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="B" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="C" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="D" type="xs:string" minOccurs="1"
maxOccurs="unbounded" />
</xs:all>
</xs:complexType>
</xs:element>
Any ideas how to achive the same with valid XSD?
Thanks in advance,
Felix