XSD - best way to do specify several similar elements

Discussion in 'XML' started by beethoven_forever, Jul 15, 2005.

  1. I'm writing a schema and want a certain element to be specified to have
    zero or more of four, similar child elements like so...

    <object>
    <integer name="Foo" value="-14"/>
    <flag name="IsBar" value="true"/>
    <flag name="IsWeighty" value="false"/>
    <string name="Doofus" value="cuddly"/>
    <script name="OnJump" value="JumpHandler"/>
    </object>

    ....where each element's "value" attribute is required to have a
    different data type (xs:integer for integer, xs:boolean for flag,
    xs:string for string and script).

    My question is, how do I avoid rewriting almost duplicate code (below)
    for each element?

    <xs:element name="integer" minOccurs="0" maxOccurs="unbounded">
    <xs:attribute name="name" type="xs:string" use="required"/>
    <xs:attribute name="value" type="xs:integer" use="required"/>
    </xs:element>

    <xs:element name="flag" minOccurs="0" maxOccurs="unbounded">
    <xs:attribute name="name" type="xs:string" use="required"/>
    <xs:attribute name="value" type="xs:boolean" use="required"/>
    </xs:element>

    ....etc...
     
    beethoven_forever, Jul 15, 2005
    #1
    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. unishippers.suckfeed.newshosting.com

    XSD - proper way to express group of elements...

    unishippers.suckfeed.newshosting.com, Nov 3, 2004, in forum: XML
    Replies:
    1
    Views:
    353
    Priscilla Walmsley
    Nov 4, 2004
  2. Gerald Aichholzer
    Replies:
    2
    Views:
    2,074
    David Carlisle
    Jul 17, 2005
  3. Replies:
    2
    Views:
    538
    Henry S. Thompson
    Oct 18, 2005
  4. Kevin
    Replies:
    16
    Views:
    47,304
    Roedy Green
    Jan 30, 2008
  5. Victor \Zverok\ Shepelev

    RDOC: several related modules in several C files

    Victor \Zverok\ Shepelev, Mar 6, 2007, in forum: Ruby
    Replies:
    3
    Views:
    185
    Max Lapshin
    Mar 16, 2007
Loading...

Share This Page