My xml file has the tags in the below format.
say :
<country>
<city>
<st>
<no>5</no>
</st>
</city>
<village>
<st>
<no>4</no>
</st>
</village>
</country>
Can the tag <st> be present within 2 different parents?
If yes, how do I differentiate <st> in each case?
Regards
Meenakshi
Meenakshi wrote:
> Can the tag <st> be present within 2 different parents?
Yes, of course.
> If yes, how do I differentiate <st> in each case?
Do you want to write a schema for that XML? Or do you want to query the XML?
Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/
|||I need to write a scema for that XML.
How do I do that?
Regards
Meena
"Martin Honnen" <mahotrash@.yahoo.de> wrote in message
news:OM5sj5JwHHA.4528@.TK2MSFTNGP03.phx.gbl...
> Meenakshi wrote:
>
> Yes, of course.
>
> Do you want to write a schema for that XML? Or do you want to query the
> XML?
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/
|||Meenakshi wrote:
> I need to write a scema for that XML.
> How do I do that?
Here is an example schema that inlines the element definitions:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xs:element name="country">
<xs:complexType>
<xs:sequence>
<xs:element name="city">
<xs:complexType>
<xs:sequence>
<xs:element name="st">
<xs:complexType>
<xs:sequence>
<xs:element name="no" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="village">
<xs:complexType>
<xs:sequence>
<xs:element name="st">
<xs:complexType>
<xs:sequence>
<xs:element name="no" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Another solution would be to define a complexType and reference that as
follows:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xs:complexType name="typeName">
<xs:sequence>
<xs:element name="st">
<xs:complexType>
<xs:sequence>
<xs:element name="no" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="country">
<xs:complexType>
<xs:sequence>
<xs:element name="city" type="typeName"></xs:element>
<xs:element name="village" type="typeName"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/
|||Thank You
"Martin Honnen" <mahotrash@.yahoo.de> wrote in message
news:%23fG8lyhwHHA.1212@.TK2MSFTNGP05.phx.gbl...
> Meenakshi wrote:
> Here is an example schema that inlines the element definitions:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
> <xs:element name="country">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="city">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="st">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="no" type="xs:int"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="village">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="st">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="no" type="xs:int"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> Another solution would be to define a complexType and reference that as
> follows:
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
> <xs:complexType name="typeName">
> <xs:sequence>
> <xs:element name="st">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="no" type="xs:int"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="country">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="city" type="typeName"></xs:element>
> <xs:element name="village" type="typeName"></xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment