XML Schemas...

Discussion in 'XML' started by abu.butt@gmail.com, Feb 21, 2005.

  1. Guest

    Hi,

    I am still a newbie with XML and was hoping someone could help me with
    this query. I want to create an XML Schema that would allow me to have
    two elements that have a different structure in two different areas of
    XML. It's probably easier if I provide a sample XML :-

    <MyXML>
    <MDP type="MDP">
    <linkFactor type="linkFactor">
    <value type="decimal">0.9</value>
    </linkFactor>
    </MDP>
    <MDS type="MDS">
    <linkFactor type="linkFactor">0.90</linkFactor>
    </MDS>
    </MyXML>

    Basically, in the above sample linkfactor is present twice, but in the
    MDP section I want it to have a value tag.

    Is it possible to create an XML Schema to correspond to this ?
    I was thinking I need to hide the definitions of linkfactor so that I
    have two one for each element. My thoughts of what the actual schema
    defn. of this type would be

    <xs:complexType name="linkFactorType" mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="value" type="valueType"/>
    </xs:choice>
    <xs:attribute name="type" type="xs:string" use="required"/>
    </xs:complexType>

    for the expanded version that includes the value tag and

    <xs:element name="linkFactor" type="linkFactorType"/>

    for the simpler type. Just confused on how to pick-up one defn over the
    other.


    Any guidance greatly appreciated.

    Many Thanks,
    Ab
    , Feb 21, 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. Soeren
    Replies:
    2
    Views:
    344
    Waxolunist
    Sep 22, 2004
  2. Replies:
    3
    Views:
    780
  3. Replies:
    1
    Views:
    573
    Roedy Green
    Aug 30, 2005
  4. Tony Prichard
    Replies:
    0
    Views:
    713
    Tony Prichard
    Dec 12, 2003
  5. Andy B
    Replies:
    0
    Views:
    368
    Andy B
    Aug 7, 2008
Loading...

Share This Page