Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Schema question regarding some mandatory/some optional values

Reply
Thread Tools

Schema question regarding some mandatory/some optional values

 
 
Piers Chivers
Guest
Posts: n/a
 
      02-26-2004
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


 
Reply With Quote
 
 
 
 
Martin SChukrazy
Guest
Posts: n/a
 
      02-27-2004
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:c1ldri$9p5$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Piers Chivers
Guest
Posts: n/a
 
      03-02-2004
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" <(E-Mail Removed)> wrote in message
news:403f9be0$0$3097$(E-Mail Removed)...
> 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:c1ldri$9p5$(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write an XML schema that specifies an optional namespace inthe XML docs? Jethrie-JDuprez in the news XML 4 04-26-2009 08:35 PM
W3C Schema for required and optional elements Philipp XML 2 04-11-2008 09:17 AM
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
Xml schema element with attribute and optional simple content? Gazza XML 1 12-05-2005 05:32 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM



Advertisments