|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Elements with same name and different data type
Hi,
I have the following XML document
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="myTesting.xsd">
<Element>
<Child1/>
</Element>
<Element>
<Child2/>
</Element>
</Root>
As shown above, the XML root tag in-turn contains two "element" tags which
has different child element.
I defined the schema for the above XML file as follows
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Child1">
<xs:complexType/>
</xs:element>
<xs:element name="Child2">
<xs:complexType/>
</xs:element>
<xs:complexType name="ElementType1">
<xs:sequence>
<xs:element ref="Child1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ElementType2">
<xs:sequence>
<xs:element ref="Child2"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Root">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="Element"
type="ElementType1" maxOccurs="unbounded"/>
</xs:sequence>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="Element"
type="ElementType2" maxOccurs="unbounded"/>
</xs:sequence>
<!-- Other Similar elements will go here -->
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
I validated XML document with XMLSpy and the document is valid as per the
schema.
When I try to validate the XML document using Xerces, I got the following
error.
"Multiple elements with name 'Element', with different types, appear in the
model group"
With the above error message, It looks like the XML schema file is not
valid. But I am not sure how XMLSpy is
validating this file successfully
Thanks,
Srini.
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||







