Defining elements in XML Scheme

Discussion in 'XML' started by Ian Partridge, Oct 31, 2003.

  1. Hi,

    I'm having some problems working out how my XML Schema should be
    constructed. Simply, if I have XML like:

    <basetag>
    <tag1>foo</tag1>
    <tag2>bar</tag2>
    <tag1>foo</tag1>
    <tag2>bar</tag2>
    <tag2>bar</tag2>
    <tag1>foo</tag1>
    <tag2>bar</tag2>
    </basetag>

    i.e. unlimited interleaved instances of tag1 and tag2 within basetag, how
    should I define my Schema to support this? I can't see how <xs:sequence> or
    <xs:choice> are appropriate in this case...

    Any tips greatly appreciated.

    Many thanks,
    Ian Partridge
     
    Ian Partridge, Oct 31, 2003
    #1
    1. Advertising

  2. In article <Xns94258F11AC73Dipartridgeukibmcom@9.20.142.8>,
    Ian Partridge <> wrote:

    % constructed. Simply, if I have XML like:
    %
    % <basetag>
    % <tag1>foo</tag1>
    % <tag2>bar</tag2>
    % <tag1>foo</tag1>
    % <tag2>bar</tag2>
    % <tag2>bar</tag2>
    % <tag1>foo</tag1>
    % <tag2>bar</tag2>
    % </basetag>
    %
    % i.e. unlimited interleaved instances of tag1 and tag2 within basetag, how
    % should I define my Schema to support this? I can't see how <xs:sequence> or
    % <xs:choice> are appropriate in this case...

    Well, is it any of tag1 or tag2, or is it tag1 then tag2, any number
    of times? From your use of interleaved, I guess it's the latter, so you
    want

    <xs:sequence maxOccurs='unbounded'>
    <xs:element name='tag1'.../>
    <xs:element name='tag2'.../>
    </xs:sequence>

    If it were the former, you'd want xs:choice.
    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Oct 31, 2003
    #2
    1. Advertising

  3. (Patrick TJ McPhee) wrote in
    news:bnueno$241$:

    > In article <Xns94258F11AC73Dipartridgeukibmcom@9.20.142.8>,
    > Ian Partridge <> wrote:
    >
    > % constructed. Simply, if I have XML like:
    > %
    > % <basetag>
    > % <tag1>foo</tag1>
    > % <tag2>bar</tag2>
    > % <tag1>foo</tag1>
    > % <tag2>bar</tag2>
    > % <tag2>bar</tag2>
    > % <tag1>foo</tag1>
    > % <tag2>bar</tag2>
    > % </basetag>
    > %
    > % i.e. unlimited interleaved instances of tag1 and tag2 within
    > basetag, how % should I define my Schema to support this? I can't see
    > how <xs:sequence> or % <xs:choice> are appropriate in this case...
    >
    > Well, is it any of tag1 or tag2, or is it tag1 then tag2, any number
    > of times? From your use of interleaved, I guess it's the latter, so
    > you want
    >
    > <xs:sequence maxOccurs='unbounded'>
    > <xs:element name='tag1'.../>
    > <xs:element name='tag2'.../>
    > </xs:sequence>
    >
    > If it were the former, you'd want xs:choice.


    It is the former, sorry, I was unclear.

    Basically tag1 and tag2 will each occur an unlimited number of times (or
    not at all), randomly in any order.

    Can I use <xs:choice> for that?

    Thanks in advance,
    Ian
     
    Ian Partridge, Nov 3, 2003
    #3
  4. Ian Partridge

    Mark Preston Guest

    On Mon, 3 Nov 2003 22:22:21 +0000 (UTC), Ian Partridge
    <> wrote:

    >Basically tag1 and tag2 will each occur an unlimited number of times (or
    >not at all), randomly in any order.
    >
    >Can I use <xs:choice> for that?
    >

    Yes, its a <choice> of either tag and in can occur up to the limit of
    how many you want in the set - in other words, a choice that can be
    repeated many times within the main tag.
     
    Mark Preston, Nov 4, 2003
    #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. Gregor Traven

    defining print size for flash elements

    Gregor Traven, Feb 16, 2005, in forum: HTML
    Replies:
    2
    Views:
    824
    Travis Newbury
    Feb 16, 2005
  2. Replies:
    3
    Views:
    564
    Priscilla Walmsley
    Oct 7, 2005
  3. johny smith
    Replies:
    8
    Views:
    449
    Peter Koch Larsen
    Jul 2, 2004
  4. Brian van den Broek

    broke IDLE while defining a key-binding scheme

    Brian van den Broek, Feb 5, 2005, in forum: Python
    Replies:
    0
    Views:
    358
    Brian van den Broek
    Feb 5, 2005
  5. Brian van den Broek
    Replies:
    0
    Views:
    292
    Brian van den Broek
    Feb 7, 2005
Loading...

Share This Page