A
Antony
Hi there, I have defined an XML schema for some information I am going
to import into a database.
What I do not know how to do in the schema is to ensure if
<numberOfItems> is 6, then there has to be 6 entries of <item> under
<listOfItems>. Currently I am having to do this in my (Java)
application code.
<dataToImport>
<numberOfItems>6</numberOfItems>
<listOfItems>
<item>GHY-098</item>
<item>GHY-108</item>
<item>GHY-109</item>
<item>GHY-112</item>
<item>GHY-113</item>
<item>GHY-999</item>
<listOfItems>
</dataToImport>
The XML above is valid when I put the following line in my schema
<xsd:element name="item" minOccurs="6" maxOccurs="6">
but not every <listOfItems> contains 6 <item> lines. I want a way of
saying that the minOccurs and maxOccurs equal the value in
<numberOfItems>, which in this case is 6 but also may be 8, or 4, or
any other number.
Can this be done in an XML Schema?
Although it is probably in this book "XML in a Nutshell, a Desktop
Quick Reference, 2nd Ed" I cannot find the information.
Thank you
Tony
to import into a database.
What I do not know how to do in the schema is to ensure if
<numberOfItems> is 6, then there has to be 6 entries of <item> under
<listOfItems>. Currently I am having to do this in my (Java)
application code.
<dataToImport>
<numberOfItems>6</numberOfItems>
<listOfItems>
<item>GHY-098</item>
<item>GHY-108</item>
<item>GHY-109</item>
<item>GHY-112</item>
<item>GHY-113</item>
<item>GHY-999</item>
<listOfItems>
</dataToImport>
The XML above is valid when I put the following line in my schema
<xsd:element name="item" minOccurs="6" maxOccurs="6">
but not every <listOfItems> contains 6 <item> lines. I want a way of
saying that the minOccurs and maxOccurs equal the value in
<numberOfItems>, which in this case is 6 but also may be 8, or 4, or
any other number.
Can this be done in an XML Schema?
Although it is probably in this book "XML in a Nutshell, a Desktop
Quick Reference, 2nd Ed" I cannot find the information.
Thank you
Tony