Page 1 of 1

Validating unordered elements with additional requirements

Posted: Wed Jan 19, 2005 1:49 am
by SwimsZoots

I have to validate an XML document where there is a parent element <Output>, which, if present must have one or both of the following child elements: <errors>, <mappings>. (max. 1 instance each, unordered).

Any ideas on what as possible schema would look like, if it is possible at all?


Try this

Posted: Wed Jan 19, 2005 5:16 pm
by Radu

Maybe try would work:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="output">
<xs:element ref="errors" minOccurs="1" maxOccurs="1"/>
<xs:element ref="mappings" minOccurs="0" maxOccurs="1"/>
<xs:element ref="mappings" minOccurs="1" maxOccurs="1"/>
<xs:element ref="errors" minOccurs="0" maxOccurs="1"/>
<xs:element name="errors"/>
<xs:element name="mappings"/>

Posted: Wed Jan 19, 2005 10:07 pm
by SwimsZoots
Thanks a bunch. This helps a lot. Plus it gives me some ideas for other things I need to do.