Schema question regarding some mandatory/some optional values

Discussion in 'XML' started by Piers Chivers, Feb 26, 2004.

  1. 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
     
    Piers Chivers, Feb 26, 2004
    #1
    1. Advertising

  2. 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$...
    > 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
    >
    >
     
    Martin SChukrazy, Feb 27, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:403f9be0$0$3097$...
    > 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$...
    > > 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
    > >
    > >

    >
    >
     
    Piers Chivers, Mar 2, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,612
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,296
    Stanimir Stamenkov
    Apr 25, 2005
  3. ANoobee
    Replies:
    3
    Views:
    398
  4. Thomas Wittek
    Replies:
    4
    Views:
    1,530
    Joe Kesselman
    Sep 13, 2007
  5. byrnejb
    Replies:
    0
    Views:
    110
    byrnejb
    Jul 15, 2010
Loading...

Share This Page