Re: Elements with maxOccurs (some unbound, some 1)

Discussion in 'XML' started by foolproofplan@gmail.com, May 23, 2007.

  1. Guest

    Boris Kolpackov <> wrote:

    > ...NameMemberReference has to come first, ParentMemberReference
    > second and the rest can come after the two in any order.


    I tried out my schema again and you're correct. I guess my solution is
    order-specific, so I can't use it.


    After discussing this problem with others, I have also found out that
    there are many more elements in this schema that need to occur once.
    So I am trying to figure out a solution that isn't so convoluted.

    I've been looking into using an <xsd:all> to list many elements as an
    extended ComplexType. However I am getting errors with the code. Does
    anyone know if it is true that <xsd:all> has certain restrictions that
    keep me from doing this?

    Here is my latest example:

    <xsd:complexType name="SingleElements">
    <xsd:all>
    <xsd:element ref="NameMemberReference" minOccurs="0"
    maxOccurs="1"/>
    <xsd:element ref="ParentMemberReference" minOccurs="0"
    maxOccurs="1"/>
    <xsd:element ref="HighlightRelated" minOccurs="0"/>
    <xsd:element ref="OnEdit" minOccurs="0"/>
    <xsd:element ref="OnCommit" minOccurs="0"/>
    <xsd:element ref="OnCancel" minOccurs="0"/>
    <xsd:element ref="PreCommitValidate" minOccurs="0"/>
    <xsd:element ref="OnDelete" minOccurs="0"/>
    <xsd:element ref="PrimaryGeometryLink" minOccurs="0"/>
    <xsd:element ref="Members" minOccurs="0"/>
    <xsd:element ref="Permissions" minOccurs="0"/>
    </xsd:all>
    </xsd:complexType>

    <xsd:element name="ObjectTemplate">
    <xsd:complexType>
    <xsd:complexContent>
    <xsd:extension base="SingleElements">
    <xsd:choice maxOccurs="unbounded">
    <xsd:element ref="License" minOccurs="0"/>
    </xsd:choice>
    <xsd:attribute ref="name" use="required"/>
    <xsd:attribute ref="id" use="required"/>
    <xsd:attribute ref="precedence"/>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>
     
    , May 23, 2007
    #1
    1. Advertising

  2. writes:

    > I've been looking into using an <xsd:all> to list many elements as an
    > extended ComplexType. However I am getting errors with the code. Does
    > anyone know if it is true that <xsd:all> has certain restrictions that
    > keep me from doing this?


    Yes, the xs:all compositor has a number of restrictions, including:

    (1) It cannot be used inside other compositors

    (2) It can only contain xs:element particles with maxOccurs="1"

    (3) It cannot be derived by extension

    I think your (sensible) choices boil down to either using the ordered
    sequence (for example you can put all optional elements first followed
    by multiple occurrence elements) or enforcing some constrains in the
    application.

    hth,
    -boris
    --
    Boris Kolpackov
    Code Synthesis Tools CC
    http://www.codesynthesis.com
    Open-Source, Cross-Platform C++ XML Data Binding
     
    Boris Kolpackov, May 24, 2007
    #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. Mavis
    Replies:
    0
    Views:
    443
    Mavis
    Jun 1, 2006
  2. mavis
    Replies:
    2
    Views:
    3,766
    mavis
    Jun 1, 2006
  3. Replies:
    2
    Views:
    2,168
    Joe Kesselman
    Jun 5, 2006
  4. Replies:
    3
    Views:
    432
    Joseph Kesselman
    May 23, 2007
  5. Replies:
    2
    Views:
    468
    Boris Kolpackov
    May 23, 2007
Loading...

Share This Page