Need recommendations about XML schema architecture

Discussion in 'XML' started by Alex, Mar 19, 2010.

  1. Alex

    Alex Guest

    Hello, XML experts

    I'm trying to define an XML schema for documents, which have never
    been validated, so their design is far from perfect. For example,
    elements with the same tag inside different elements have different
    meanings:

    <abc>
    <def>
    <xyz ..... />
    </def>
    <ghi>
    <xyz ..... />
    </ghi>
    </abc>

    I'd like to create a schema, where all the elements are declared at a
    global level, and then combine them using references. But it looks
    like the element <xyz> can't be defined at global level, cause it
    actually has two different types, depending on the parent element:

    <xsd:schema ...>
    <xs:element name="abc" ...../>
    <xs:element name="def" ...../>
    <xs:element name="ghi" ...../>
    <xs:element name="xyz" ...../> <!-- cannot be here???? -->
    </xsd:schema>

    Could you please advise how to use the XSD for such case?

    Thank you in advance
    Alex
     
    Alex, Mar 19, 2010
    #1
    1. Advertisements

  2. Define the elements that are children inline e.g.
    <xs:element name="abc">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="def">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="xyz"/>
     
    Martin Honnen, Mar 19, 2010
    #2
    1. Advertisements

  3. Alex

    Alex Guest

    I was trying to avoid packing everything to a single big tree. I've
    found that I can split this tree into parts using
    "xs:complexType"s ...

    Thank you,
    Alex
     
    Alex, Mar 19, 2010
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.