XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS