xs:sequence and xs:all

Discussion in 'XML' started by JBB, Nov 13, 2007.

  1. JBB

    JBB Guest

    Hello,

    I'd like to have an xsd schema representing an XMl looking like this:

    <Object>
    <PARAM_A>456</PARAM_A>
    <PARAM_B>45</PARAM_B>
    <Value>0</Value>
    <Value>10</Value>
    <Value>12</Value>
    <Value>63</Value>
    <Value>41</Value>
    <Value>53</Value>
    <Value>62</Value>
    ....
    <Value>10</Value>
    </Object>

    it works whith using xs:sequence

    <xs:element name="Object">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="PARAM_A" />
    <xs:element name="PARAM_B" />
    <xs:element name="Value" maxOccurs="unbounded" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    but I'd like to be able to switch the order on PARAM_A and PARAM_B
    so that
    <Object>
    <PARAM_B>45</PARAM_B>
    <PARAM_A>456</PARAM_A>
    <Value>0</Value>
    <Value>5</Value>
    <Value>10</Value>
    </Object>
    wotks too.

    then I try the xs:all attribute in stead of xs:sequence but it doesn't work.
    <xs:element name="Object">
    <xs:complexType>
    <xs:all>
    <xs:element name="PARAM_A" />
    <xs:element name="PARAM_B" />
    <xs:element name="Value" maxOccurs="unbounded" />
    </xs:all>
    </xs:complexType>
    </xs:element>

    Is it possible to do that?

    Thanks,
     
    JBB, Nov 13, 2007
    #1
    1. Advertising

  2. JBB

    Pavel Lepin Guest

    JBB <> wrote in <fhbtup$8f4$>:
    > it works whith using xs:sequence
    >
    > <xs:element name="Object">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="PARAM_A" />
    > <xs:element name="PARAM_B" />
    > <xs:element name="Value"
    > maxOccurs="unbounded" />
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    >
    > but I'd like to be able to switch the order on PARAM_A and
    > PARAM_B


    <xs:complexType>
    <xs:sequence>
    <xs:choice>
    <xs:sequence>
    <xs:element name="PARAM_A"/>
    <xs:element name="PARAM_B"/>
    </xs:sequence>
    <xs:sequence>
    <xs:element name="PARAM_B"/>
    <xs:element name="PARAM_A"/>
    </xs:sequence>
    </xs:choice>
    <xs:element name="Value" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>

    Beware of combinatorial explosion. Down this path lies
    madness.

    --
    ....also, I submit that we all must honourably commit seppuku
    right now rather than serve the Dark Side by producing the
    HTML 5 spec.
     
    Pavel Lepin, Nov 13, 2007
    #2
    1. Advertising

  3. JBB

    JBB Guest

    Pavel Lepin a écrit :
    >
    > <xs:complexType>
    > <xs:sequence>
    > <xs:choice>
    > <xs:sequence>
    > <xs:element name="PARAM_A"/>
    > <xs:element name="PARAM_B"/>
    > </xs:sequence>
    > <xs:sequence>
    > <xs:element name="PARAM_B"/>
    > <xs:element name="PARAM_A"/>
    > </xs:sequence>
    > </xs:choice>
    > <xs:element name="Value" maxOccurs="unbounded"/>
    > </xs:sequence>
    > </xs:complexType>
    >
    > Beware of combinatorial explosion. Down this path lies
    > madness.
    >

    Yes, in my real problem I've got 5 PARAM ...

    why is that not correct?
    <xs:complexType>
    <xs:sequence>
    <xs:all>
    <xs:element name="PARAM_A" type="xs:string"/>
    <xs:element name="PARAM_B" type="xs:string"/>
    </xs:all>
    <xs:element name="Value" maxOccurs="unbounded" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>

    Is there a rule that says: you can use sequence in choice, choice in sequence, but you can't use all in sequence...
    Where can i find such rules?link?
    Is there an xsd schema on xsd syntax?
     
    JBB, Nov 14, 2007
    #3
  4. JBB

    Pavel Lepin Guest

    JBB <> wrote in <fhef4r$r2a$>:
    > Pavel Lepin a écrit :
    >> <xs:complexType>
    >> <xs:sequence>
    >> <xs:choice>
    >> <xs:sequence>
    >> <xs:element name="PARAM_A"/>
    >> <xs:element name="PARAM_B"/>
    >> </xs:sequence>
    >> <xs:sequence>
    >> <xs:element name="PARAM_B"/>
    >> <xs:element name="PARAM_A"/>
    >> </xs:sequence>
    >> </xs:choice>
    >> <xs:element name="Value" maxOccurs="unbounded"/>
    >> </xs:sequence>
    >> </xs:complexType>
    >>
    >> Beware of combinatorial explosion. Down this path lies
    >> madness.

    >
    > Yes, in my real problem I've got 5 PARAM ...


    So use a restrictive schema. There are few reasons not to,
    and fewer of them are truly valid.

    > why is that not correct?


    Because the spec says so.

    > Where can i find such rules?link?


    Google is your friend.

    > Is there a rule that says: you can use sequence in choice,
    > choice in sequence, but you can't use all in sequence...


    http://www.w3.org/TR/xmlschema-1/#Model_Groups

    > Is there an xsd schema on xsd syntax?


    http://www.w3.org/TR/xmlschema-1/#normative-schemaSchema

    --
    ....also, I submit that we all must honourably commit seppuku
    right now rather than serve the Dark Side by producing the
    HTML 5 spec.
     
    Pavel Lepin, Nov 14, 2007
    #4
  5. JBB

    JBB Guest

    Pavel Lepin a écrit :
    > JBB <> wrote in <fhef4r$r2a$>:
    >> Pavel Lepin a écrit :
    >>> <xs:complexType>
    >>> <xs:sequence>
    >>> <xs:choice>
    >>> <xs:sequence>
    >>> <xs:element name="PARAM_A"/>
    >>> <xs:element name="PARAM_B"/>
    >>> </xs:sequence>
    >>> <xs:sequence>
    >>> <xs:element name="PARAM_B"/>
    >>> <xs:element name="PARAM_A"/>
    >>> </xs:sequence>
    >>> </xs:choice>
    >>> <xs:element name="Value" maxOccurs="unbounded"/>
    >>> </xs:sequence>
    >>> </xs:complexType>
    >>>
    >>> Beware of combinatorial explosion. Down this path lies
    >>> madness.

    >> Yes, in my real problem I've got 5 PARAM ...

    >
    > So use a restrictive schema. There are few reasons not to,
    > and fewer of them are truly valid.
    >
    >> why is that not correct?

    >
    > Because the spec says so.
    >
    >> Where can i find such rules?link?

    >
    > Google is your friend.
    >
    >> Is there a rule that says: you can use sequence in choice,
    >> choice in sequence, but you can't use all in sequence...

    >
    > http://www.w3.org/TR/xmlschema-1/#Model_Groups
    >
    >> Is there an xsd schema on xsd syntax?

    >
    > http://www.w3.org/TR/xmlschema-1/#normative-schemaSchema
    >

    Thank you very much
     
    JBB, Nov 14, 2007
    #5
    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. zorro
    Replies:
    0
    Views:
    456
    zorro
    Jul 31, 2004
  2. melograno
    Replies:
    3
    Views:
    470
    Arthur
    Apr 29, 2005
  3. chandanlinster

    printing all escape sequence characters

    chandanlinster, Oct 28, 2006, in forum: C Programming
    Replies:
    5
    Views:
    350
    Kenneth Brody
    Oct 30, 2006
  4. Daneel
    Replies:
    8
    Views:
    328
  5. stef mientki
    Replies:
    13
    Views:
    687
    stef mientki
    Oct 20, 2007
Loading...

Share This Page