Occurence constraints in XSD

Discussion in 'XML' started by Roland, Sep 25, 2003.

  1. Roland

    Roland Guest

    hi all

    having designed my schema to use repeating groups of elements, I found
    that some applications (eg. Microsoft InfoPath) refused to recognised
    that element as a repeating element.

    I subsequently found that out of the three possible ways (that I know
    of) of declaring repeating elements in xsd, only one of these was
    understood:

    a) occurence constraint on the child element contained in a sequence
    compositor IS recognised as a repeating element.
    b) occurence constraint on sequence compositor containing the child
    element IS NOT recognised as a repeating element.
    c) occurence constraint on group reference where the goup is a
    sequence compositor containing the child element IS NOT recognised as
    a repeating element.

    as can be seen from the following xsd schema:

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="testRepeating">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="RepeatingChildren">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="repeatingChild" minOccurs="0"
    maxOccurs="10"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="RepeatingSequence">
    <xsd:complexType>
    <xsd:sequence minOccurs="0" maxOccurs="10">
    <xsd:element ref="repeatingChild"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="RepeatingGroup" type="repeatingGroupType">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="repeatingChild" type="xsd:string"/>
    <xsd:group name="repeatingGroup">
    <xsd:sequence>
    <xsd:element ref="repeatingChild"/>
    </xsd:sequence>
    </xsd:group>
    <xsd:complexType name="repeatingGroupType">
    <xsd:group ref="repeatingGroup" minOccurs="0" maxOccurs="10"/>
    </xsd:complexType>
    </xsd:schema>


    only the "//testRepeating/RepeatingChildren/repeatingChild" XPath in
    a document instance based on the above schema was treated by the
    application as a repeating element.


    ignoring that particular limitation, I would like to know which of the
    three models above that allow repeating elements is the most
    recommended approach, and why ?


    thanks
    roland
     
    Roland, Sep 25, 2003
    #1
    1. Advertisements

  2. Roland wrote:

    > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    > <xsd:element name="testRepeating">
    > <xsd:complexType>
    > <xsd:sequence>
    > <xsd:element name="RepeatingChildren">
    > <xsd:complexType>
    > <xsd:sequence>
    > <xsd:element ref="repeatingChild" minOccurs="0"
    > maxOccurs="10"/>
    > </xsd:sequence>
    > </xsd:complexType>
    > </xsd:element>
    > <xsd:element name="RepeatingSequence">
    > <xsd:complexType>
    > <xsd:sequence minOccurs="0" maxOccurs="10">
    > <xsd:element ref="repeatingChild"/>
    > </xsd:sequence>
    > </xsd:complexType>
    > </xsd:element>
    > <xsd:element name="RepeatingGroup" type="repeatingGroupType">
    > </xsd:element>
    > </xsd:sequence>
    > </xsd:complexType>
    > </xsd:element>
    > <xsd:element name="repeatingChild" type="xsd:string"/>
    > <xsd:group name="repeatingGroup">
    > <xsd:sequence>
    > <xsd:element ref="repeatingChild"/>
    > </xsd:sequence>
    > </xsd:group>
    > <xsd:complexType name="repeatingGroupType">
    > <xsd:group ref="repeatingGroup" minOccurs="0" maxOccurs="10"/>
    > </xsd:complexType>
    > </xsd:schema>


    ....
    > ignoring that particular limitation, I would like to know which of the
    > three models above that allow repeating elements is the most
    > recommended approach, and why ?


    I'd say all three are just different ways to express the same constraint.
    Second and third are a bit redundant ones for only defining maxOccurence of a
    single element, but I believe all of them are valid though.
    --
    Oleg Tkachenko
    http://www.tkachenko.com/blog
    Multiconn Technologies, Israel
     
    Oleg Tkachenko, Sep 25, 2003
    #2
    1. Advertisements

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,666
    Markus
    Nov 22, 2005
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    708
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Replies:
    1
    Views:
    1,206
    Martin Honnen
    Jan 14, 2004
  4. Peter Aberline

    xsd:any as a child of xsd:all

    Peter Aberline, Apr 5, 2004, in forum: XML
    Replies:
    0
    Views:
    1,020
    Peter Aberline
    Apr 5, 2004
  5. Bernd Oninger
    Replies:
    1
    Views:
    748
    Henry S. Thompson
    Jun 30, 2004
  6. Burak
    Replies:
    0
    Views:
    681
    Burak
    Jul 1, 2004
  7. Matt
    Replies:
    3
    Views:
    37,721
    MKNDK
    Sep 11, 2008
  8. Steve Fletcher

    XSD Constraints

    Steve Fletcher, Feb 1, 2008, in forum: XML
    Replies:
    1
    Views:
    717
    Pavel Lepin
    Feb 1, 2008
Loading...