473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Schema question regarding some mandatory/some optional values

Hi,
I have XML like

<SomeElement>
<Value>5</Value>
<Value>3</Value>
<Value>7</Value>
</SomeElement>

I want to define the schema to say that the <Value>s must contain at least
one of a number of known values, and may contain some other <Value>s. For
example, if the known <Value>s were 3 and 5 then the above is valid. Also,

<SomeElement>
<Value>5</Value>
<Value>1</Value>
</SomeElement>

AND

<SomeElement>
<Value>3<Value>
</SomeElement>

are valid because they contain one of (3 and 5). But

<SomeElement>
<Value>8</Value>
</SomeElement>

is not valid. I've tried defining this using xs:all and enumerations but
with no luck. All suggestions gratefully received.

Thanks,
Piers
Jul 20 '05 #1
2 1380
One suggestion is to change the
<Value>5</Value>
to a
<Value5>...</Value5>
That way you can have multiple values i.e. each value is equal to an element
and hence write a DTD/Schema that makes it conform to your rules defined
below...
"Piers Chivers" <Piers.Chivers@_no_spam_.btinternet.com> wrote in message
news:c1**********@hercules.btinternet.com...
Hi,
I have XML like

<SomeElement>
<Value>5</Value>
<Value>3</Value>
<Value>7</Value>
</SomeElement>

I want to define the schema to say that the <Value>s must contain at least
one of a number of known values, and may contain some other <Value>s. For
example, if the known <Value>s were 3 and 5 then the above is valid. Also,
<SomeElement>
<Value>5</Value>
<Value>1</Value>
</SomeElement>

AND

<SomeElement>
<Value>3<Value>
</SomeElement>

are valid because they contain one of (3 and 5). But

<SomeElement>
<Value>8</Value>
</SomeElement>

is not valid. I've tried defining this using xs:all and enumerations but
with no luck. All suggestions gratefully received.

Thanks,
Piers

Jul 20 '05 #2
I don't think this can work. It doesn't feel instinctively right (not that
my XML instincts are particularly good!). The mian problem though is that I
don't know what all of the possible values are. I might have a Value1002 or
Value27649 etc. How do I represent this in a schema?

I'm surprised this is so difficult. I would have thought that a schema that
said "Many values allowed but at least one of them must be blahblah" isn't
such an unusual request??

Piers
"Martin SChukrazy" <pr****@hotmail.com> wrote in message
news:40**********************@news.rcn.com...
One suggestion is to change the
<Value>5</Value>
to a
<Value5>...</Value5>
That way you can have multiple values i.e. each value is equal to an element and hence write a DTD/Schema that makes it conform to your rules defined
below...
"Piers Chivers" <Piers.Chivers@_no_spam_.btinternet.com> wrote in message
news:c1**********@hercules.btinternet.com...
Hi,
I have XML like

<SomeElement>
<Value>5</Value>
<Value>3</Value>
<Value>7</Value>
</SomeElement>

I want to define the schema to say that the <Value>s must contain at least one of a number of known values, and may contain some other <Value>s. For example, if the known <Value>s were 3 and 5 then the above is valid.

Also,

<SomeElement>
<Value>5</Value>
<Value>1</Value>
</SomeElement>

AND

<SomeElement>
<Value>3<Value>
</SomeElement>

are valid because they contain one of (3 and 5). But

<SomeElement>
<Value>8</Value>
</SomeElement>

is not valid. I've tried defining this using xs:all and enumerations but with no luck. All suggestions gratefully received.

Thanks,
Piers


Jul 20 '05 #3

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

Similar topics

1
by: Alex Sab | last post by:
Hi, I am having trouble describing in a schema that elements can be mandatory in one part and not mandatory in another part of the xml document. Here is a sample xml file <Model:Templates>...
1
by: Maxim | last post by:
If there is a document like this: <Configurations> <Configuration default="true"> ... </Configuration> <Configuration> ...
2
by: Th.-Fischer | last post by:
hi, i have this xml structure <users> <user id="root"/> <!-- mandatory! --> <user id="a"/> <!-- optional --> <user id="b"/> <!-- optional --> <user id="c"/> <!-- optional -->...
0
by: Sahmiac | last post by:
Hello Everyone, I'm sure this question has been asked a million times, but I'm going crazy trying to get my xml validation to work. I've spent the day reading msdn, the dot net documentation and...
1
by: Le Tubs | last post by:
Hi I am wondering if anybody has come accross this problem before, basically I have to validate a xml schema (not the data, this is done at a later stage). The only problem is that there are...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
4
by: Eric | last post by:
Attached is an example of my question. Note the "values" attribute is optional. Also the <valuesub-element is optional. Here, the XML can contain, 1 or both or neither. I would like to allow...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
2
by: BD | last post by:
I'm working with a data model which is managed in the AllFusion ERwin tool. Within the modeler, some of the FK relationships are 'non-mandatory' - which is to say that for a given child value, a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...

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.