Re: elements with the same name

> There is one tag name <Address>, but based on its
> attribute value of "type", the elements inside of
> <Address> varies.  

I would do it like so:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
 <xsd:element name="top">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name="Address" type="US"/>
    <xsd:element name="Address" type="China"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 <xsd:complexType name="US">
  <xsd:sequence>
   <xsd:element name="Street" type="xsd:string"/>
   <xsd:element name="City" type="xsd:string"/>
   <xsd:element name="Zip" type="xsd:string"/>
  </xsd:sequence>
 </xsd:complexType>
 <xsd:complexType name="China">
  <xsd:sequence>
   <xsd:element name="Street" type="xsd:string"/>
   <xsd:element name="City" type="xsd:string"/>
   <xsd:element name="Province" type="xsd:string"/>
  </xsd:sequence>
 </xsd:complexType>
</xsd:schema>

Then your XML would look like this:
<top xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
 <Address xsi:type="US">
  <Street>12345 main street</Street>
  <City>JoeTown</City>
  <Zip>2456</Zip>
 </Address>
 <Address xsi:type="China">
  <Street>12344 lo pai street</Street>
  <City>...</City>
  <Province>..</Province>
 </Address>
</top>

Note the xsi:type and the declaration of the Schema Instance namespace.

-- Dave
D Gross
justdave@onebox.com - email
(312) 777-4000 x7673 - voicemail/fax



__________________________________________________
FREE voicemail, email, and fax...all in one place.
Sign Up Now! http://www.onebox.com

Received on Wednesday, 22 August 2001 11:48:35 UTC