XSD question (same attributes, different elements...)

Discussion in 'XML' started by Gooseman, Jan 22, 2004.

  1. Gooseman

    Gooseman Guest

    Hi

    Just getting into XSD and have some questions:

    If I have several different elements that all have identical
    attibutes, what is the best way of conveying that in the XSD?

    Is there a way of defining that an attribute must be either xs:ID OR a
    set of predefined lables (ie something like xs:ID | "specific_lable_1"
    | "specific_lable_2" ?

    The XSD schema I am writing is fully defined, yet some of the
    attributes for the various elements are yet to be implemented. What's
    the best way of adding a "not yet implemented" flag to these
    attributes?

    Thanks!
     
    Gooseman, Jan 22, 2004
    #1
    1. Advertising

  2. On 22/01/2004, around 11:24, Gooseman wrote:
    G> Hi

    G> Just getting into XSD and have some questions:

    G> If I have several different elements that all have identical
    G> attibutes, what is the best way of conveying that in the XSD?
    You want to look up 'attribute groups' ...

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="root">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="element1"/>
    </xs:sequence>
    <xs:attributeGroup ref="ag1"/>
    </xs:complexType>
    </xs:element>
    <xs:element name="element1" type="xs:string"/>
    <xs:attribute name="att1" type="xs:string"/>
    <xs:attribute name="att2" type="xs:string"/>
    <xs:attribute name="att3" type="xs:string"/>
    <xs:attributeGroup name="ag1">
    <xs:attribute ref="att1" use="required"/>
    <xs:attribute ref="att2" use="optional"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="ag2">
    <xs:attribute ref="att2" use="required"/>
    <xs:attribute ref="att3" use="required"/>
    </xs:attributeGroup>
    </xs:schema>

    --
    Stuart
    Friends may come and go, but enemies accumulate.
     
    DFN-CIS NetNews Service, Jan 22, 2004
    #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. Replies:
    2
    Views:
    429
    Stan Kitsis [MSFT]
    Mar 24, 2005
  2. Replies:
    1
    Views:
    458
    Johannes Koch
    Jan 31, 2006
  3. Christopher Brewster
    Replies:
    5
    Views:
    346
    John Machin
    Nov 14, 2008
  4. bluebaron
    Replies:
    3
    Views:
    747
    Jonathan N. Little
    Nov 4, 2009
  5. Guest
    Replies:
    2
    Views:
    180
    Foo Man Chew
    Dec 29, 2003
Loading...

Share This Page