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

  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. 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. Dustin D.
    Replies:
    1
    Views:
    11,217
  2. Mr Ideas Man

    Occurence of Char!

    Mr Ideas Man, Feb 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    488
    Terry Burns
    Feb 10, 2006
  3. natG
    Replies:
    4
    Views:
    9,676
  4. Armin Wagenknecht
    Replies:
    0
    Views:
    385
    Armin Wagenknecht
    May 4, 2004
  5. Steve Fletcher

    XSD Constraints

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

Share This Page