473,499 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML schema validation question

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
Jul 20 '05 #1
1 1713
minOccurs="6" maxOccurs="6"

Bob Foster

"Antony" <to****************@hotmail.com> wrote in message
news:37**************************@posting.google.c om...
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

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2829
by: Mike | last post by:
Note: My XML experience to date has (unfortunately) been limited to reading and thinking, rather than implementation. Anyway, I am in the process of trying to figure out the most efficient way...
2
2130
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
3
1844
by: Leonid Shprekher | last post by:
Question to the Schema pro: If nillable="False" is default for Schema element, why schema validation of my XML doesn't fail if I don't provide any value for the tag? Thanks, Leonid.
2
9440
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data....
1
2313
by: Dan Bass | last post by:
There's an XML message I have, that has no namespace information. Then there is a XSD schema that is must validate against, but this has a targetNamespace and xmlns of...
12
4921
by: Stefano | last post by:
Hi all, what is the correct use of the "default" attribute in XML Schema? For example: <xs:element name="myProperty" type="xs:string" default="myDefaultValue"/> What can I do with it? What...
2
7279
by: Ali | last post by:
I am having problem compiling schema contained in WSDL file when analyzing schema types contained in it (for example http://www.ebout.net/net/GoogleSearch.wsdl). Following code demonstrates my...
1
6377
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i...
5
3660
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail...
0
2674
by: Mark Parter | last post by:
I'm trying convert an XML Schema (http://www.elframework.org/projects/xcri/efc_r1.0.xsd/view) to a VB.Net class using the XSD tool provided with the .NET 2 SDK. However, it's failing to generate...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.