XSD Schema Authoring Question

Discussion in 'XML' started by Mike, Feb 5, 2008.

  1. Mike

    Mike Guest

    I'd like to create a complex type that behaves like an <xs:all> but
    has unbounded cardinality of its children. Or, another way to say it,
    is I'd like an <xs:sequence> that doesn't really care about order.
    For instance:

    <foo>
    <bar/>
    <bar/>
    <baz/>
    <bar/>
    </foo>

    and

    <foo>
    <baz/>
    </foo>

    would both match

    <xs:element name="foo">
    <xs:complexType>
    <xs:all>
    <xs:element name="bar" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="baz" />
    </xs:all>
    </xs:complexType>
    </xs:element>

    except of course for the fact that maxOccurs can only be "1" in
    <xs:all>.

    Do you see what I mean? I want to specify that these particular
    children elements can occur in their parent, in no particular (known
    to the schema) order, each with their own possibly unbounded
    cardinality. No other types of children can occur, and I want a
    validating parser to keep track of the cardinality of the children to
    ensure they're not happening too (in)frequently.

    There must be a way to do this, I just can't figure out how. Any help
    much appreciated!

    Mike
     
    Mike, Feb 5, 2008
    #1
    1. Advertising

  2. Mike

    P. Lepin Guest

    Mike wrote:
    > <foo>
    > <bar/>
    > <bar/>
    > <baz/>
    > <bar/>
    > </foo>
    >
    > and
    >
    > <foo>
    > <baz/>
    > </foo>
    >
    > would both match
    >
    > <xs:element name="foo">
    > <xs:complexType>
    > <xs:all>
    > <xs:element name="bar" minOccurs="0" maxOccurs="unbounded" />
    > <xs:element name="baz" />
    > </xs:all>
    > </xs:complexType>
    > </xs:element>
    >
    > except of course for the fact that maxOccurs can only be "1" in
    > <xs:all>.
    >
    > Do you see what I mean? I want to specify that these particular
    > children elements can occur in their parent, in no particular (known
    > to the schema) order, each with their own possibly unbounded
    > cardinality. No other types of children can occur, and I want a
    > validating parser to keep track of the cardinality of the children to
    > ensure they're not happening too (in)frequently.


    I believe this isn't possible. Either specify a strict ordering of elements
    (xs:sequence), or allow any number of applicable elements (xs:choice with
    minOccurs/maxOccurs). Check semantics on the application-side if necessary,
    and/or use a more powerful schema definition language. W3C's XML Schema
    Definition Language was not designed to define arbitrarily complex
    grammars.

    > There must be a way to do this, I just can't figure out how. Any help
    > much appreciated!


    The fact that you want to do something doesn't yet mean it's possible.

    --
    Presented in Brain Control where available.
     
    P. Lepin, Feb 5, 2008
    #2
    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,613
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,296
    Stanimir Stamenkov
    Apr 25, 2005
  3. stiank81
    Replies:
    4
    Views:
    15,454
    stiank81
    Jun 26, 2005
  4. Rushi
    Replies:
    1
    Views:
    562
  5. Replies:
    5
    Views:
    1,057
    Brian McCauley
    Nov 29, 2006
Loading...

Share This Page