Need recommendations about XML schema architecture

A

Alex

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
 
M

Martin Honnen

Alex said:
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?

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"/>
 
A

Alex

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"/>

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top