sequence - no, all - no, choice - no

Discussion in 'XML' started by melograno, Mar 6, 2005.

  1. melograno

    melograno Guest

    Sorry if this question or a similar one was already submitted into
    this newsgroup, but my investigations on this topic were not
    successfull.

    An external application that is not under my control generates an XML
    documents with 5 fields. 3 of them (f1, f3, f5) are mandatory, 2 of
    them (f2 and f4) are optionals. The field order is unpredictable. A
    couple of examples follow.

    <?xml version="1.0"?>
    <thedocument>
    <f1>11</f1>
    <f3>13</f3>
    <f5>14</f5>
    <f2>15</f2>
    </thedocument>

    <?xml version="1.0"?>
    <thedocument>
    <f4>11</f4>
    <f1>12</f1>
    <f5>13</f5>
    <f3>14</f3>
    </thedocument>

    I'm trying to define an XSD for this legacy document, but
    - sequence does not work, since the order is not fixed
    - all does not work, since some of elements are optional
    - sequence of choice does not work

    Do you have any suggestion for solving this problem?

    Thanks

    pierre
     
    melograno, Mar 6, 2005
    #1
    1. Advertising

  2. Hi Pierre,

    "all" should work for what you want. You can make the elements in an
    all group optional, as in:

    <xs:all>
    <xs:element name="f1"/>
    <xs:element name="f2" minOccurs="0"/>
    <xs:element name="f3"/>
    <xs:element name="f4" minOccurs="0"/>
    <xs:element name="f5"/>
    </xs:all>

    Hope that helps,
    Priscilla

    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Priscilla Walmsley, Mar 6, 2005
    #2
    1. Advertising

  3. melograno

    melograno Guest

    Thanks a lot, Priscilla, it worked. Part of my understanding on "all" was wrong.
    pierre

    Priscilla Walmsley <> wrote in message news:<422b9141$1_1@127.0.0.1>...
    > Hi Pierre,
    >
    > "all" should work for what you want. You can make the elements in an
    > all group optional, as in:
    >
    > <xs:all>
    > <xs:element name="f1"/>
    > <xs:element name="f2" minOccurs="0"/>
    > <xs:element name="f3"/>
    > <xs:element name="f4" minOccurs="0"/>
    > <xs:element name="f5"/>
    > </xs:all>
    >
    > Hope that helps,
    > Priscilla
    >
    > ----------------------------------
    > Priscilla Walmsley
    > Author, Definitive XML Schema
    > http://www.datypic.com
    > ----------------------------------
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    melograno, Mar 9, 2005
    #3
  4. melograno

    Arthur Guest

    Hi, I have a similar dilema, however the elements f1,f2,f3... as well as
    appearing in any order, can also appear any number of times. e.g.

    <?xml version="1.0"?>
    <thedocument>
    <f1>11</f1>
    <f1>12</f1>
    <f1>16</f1>
    <f3>13</f3>
    <f5>14</f5>
    <f2>15</f2>
    <f3>21</f3>
    <f3>22</f3>
    </thedocument>

    I understand 'all' can only occur 0 or 1 times, this is no good.
    sequence is no good because of the order. What else can I do?


    melograno wrote:
    > Thanks a lot, Priscilla, it worked. Part of my understanding on "all" was wrong.
    > pierre
    >
    > Priscilla Walmsley <> wrote in message news:<422b9141$1_1@127.0.0.1>...
    >
    >>Hi Pierre,
    >>
    >>"all" should work for what you want. You can make the elements in an
    >>all group optional, as in:
    >>
    >><xs:all>
    >> <xs:element name="f1"/>
    >> <xs:element name="f2" minOccurs="0"/>
    >> <xs:element name="f3"/>
    >> <xs:element name="f4" minOccurs="0"/>
    >> <xs:element name="f5"/>
    >></xs:all>
    >>
    >>Hope that helps,
    >>Priscilla
    >>
    >>----------------------------------
    >>Priscilla Walmsley
    >>Author, Definitive XML Schema
    >>http://www.datypic.com
    >>----------------------------------
    >>
    >>*** Sent via Developersdex http://www.developersdex.com ***
    >>Don't just participate in USENET...get rewarded for it!
     
    Arthur, Apr 29, 2005
    #4
    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. Mickey Segal
    Replies:
    0
    Views:
    913
    Mickey Segal
    Feb 2, 2004
  2. zorro
    Replies:
    0
    Views:
    446
    zorro
    Jul 31, 2004
  3. miles.jg
    Replies:
    16
    Views:
    898
    Alf P. Steinbach
    Nov 14, 2007
  4. Ryan

    sequence inside a choice

    Ryan, Jun 19, 2008, in forum: XML
    Replies:
    5
    Views:
    1,694
    Martin Honnen
    Jun 20, 2008
  5. Stefano Crocco
    Replies:
    4
    Views:
    146
    Rados³aw Bu³at
    Feb 5, 2009
Loading...

Share This Page