W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2007

RE: What's a valid instance...James Clark

From: Shlomo Yona <S.Yona@F5.com>
Date: Thu, 22 Mar 2007 07:43:21 -0700
Message-ID: <B546C312A37C12438A22154026CDC7E012818BCB@exchfive.olympus.f5net.com>
To: "Pete Cordell" <petexmldev@tech-know-ware.com>, <xmlschema-dev@w3.org>

Hello,

(hope that this doesn't stray from the original topic -- I think it is
related)

I noticed something else regarding ambiguous root element(s):

If the XML Schema defines more than one element globally then any such
globally defined element can be a valid root to an XML instance document
of that XML Schema definition.


<?xml version="1.0"?>
<xsd:schema
		xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		targetNamespace="foo"
		xmlns="foo"
		elementFormDefault="qualified">

	<xsd:element name="a" type="aType"/>

	<xsd:element name="b">
		<xsd:complexType/>
	</xsd:element>
	
	<xsd:element name="c">
		<xsd:complexType/>
	</xsd:element>

	<xsd:complexType name="aType">
		<xsd:sequence>
			<xsd:element ref="b"/>
			<xsd:element ref="c"/>
		</xsd:sequence>
	</xsd:complexType>

</xsd:schema>


So:
<?xml version="1.0"?>
<b/>

is valid against the above listed schema

but also
<?xml version="1.0"?>
<a>
	<b/>
	<c/>
</a>

And also

<?xml version="1.0"?>
<c/>



Is this intentional? I mean -- I couldn't find a way to restrict a sole
root to the document.

Shlomo.
Received on Thursday, 22 March 2007 14:44:03 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:41 UTC