EDN Admin
Well-known member
I am trying to formulate an XSD definition where child elements are supposed to occur with any frequency (one can occur once or not at all, one must occur once, one can occur at any frequency, and one must occur at least once but can occur in any frequency).
Does XSD support this or is this unsupported?
Ive been trying different things like xs:all and xs:group and xs:sequence but never find an XSD that matches all of the above criteria. Even reviewed the reference at:
file:///C:/tmp/Downloads/ScrapBook/data/20110802105921/index.html
but could not find such limitations.
Here is a sample XML to illustrate my problem:
---------------------------------------------------------------------------
<Database>
<Description /> <!-- minOccurs="0" maxOccurs="1" -->
<BakFile /> <!-- minOccurs="0" maxOccurs="1" -->
<DbVolume /> <!-- minOccurs="0" maxOccurs="unbounded" -->
<RunSQL /> <!-- minOccurs="0" maxOccurs="unbounded" -->
</Database>
---------------------------------------------------------------------------
In the above sample I want:
- the Description and BakFile tags to occur only once or not at all (optionally)
- the BakFile and Volume tag can occur unbounded times or not at all (optionally)
<span style="text-decoration:underline All tags can occur in any order (to give users their freedom to organize their data as they want).
I tried xs:sequence (which is too restrictive on the sequence of all 4 elements) and I tried xs:choice maxOccurs="unbounded" (which is too open on the elements that are to occur only once)...
Can someone please give me a matching XSD for this or point me towards a list of restrictions on XSD?
Thanks a lot, Dirk
View the full article
Does XSD support this or is this unsupported?
Ive been trying different things like xs:all and xs:group and xs:sequence but never find an XSD that matches all of the above criteria. Even reviewed the reference at:
file:///C:/tmp/Downloads/ScrapBook/data/20110802105921/index.html
but could not find such limitations.
Here is a sample XML to illustrate my problem:
---------------------------------------------------------------------------
<Database>
<Description /> <!-- minOccurs="0" maxOccurs="1" -->
<BakFile /> <!-- minOccurs="0" maxOccurs="1" -->
<DbVolume /> <!-- minOccurs="0" maxOccurs="unbounded" -->
<RunSQL /> <!-- minOccurs="0" maxOccurs="unbounded" -->
</Database>
---------------------------------------------------------------------------
In the above sample I want:
- the Description and BakFile tags to occur only once or not at all (optionally)
- the BakFile and Volume tag can occur unbounded times or not at all (optionally)
<span style="text-decoration:underline All tags can occur in any order (to give users their freedom to organize their data as they want).
I tried xs:sequence (which is too restrictive on the sequence of all 4 elements) and I tried xs:choice maxOccurs="unbounded" (which is too open on the elements that are to occur only once)...
Can someone please give me a matching XSD for this or point me towards a list of restrictions on XSD?
Thanks a lot, Dirk
View the full article