Schema question regarding some mandatory/some optional values

P

Piers Chivers

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
 
M

Martin SChukrazy

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...
 
P

Piers Chivers

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top