W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2009

RE: schemaLocation declaration after namespace usage

From: Michael Kay <mike@saxonica.com>
Date: Fri, 6 Feb 2009 11:20:07 -0000
To: "'Tobias Koenig'" <tobias.koenig@trolltech.com>, <xmlschema-dev@w3.org>
Message-ID: <0F999A6FDCA24A2F8E9C9C3FC492C53C@Sealion>

> 
> http://www.w3.org/TR/xmlschema-1/#schema-loc 4) says that no 
> schemaLocation declaration is allowed to appear, after the 
> namespace has been used for a validation of an element or attribute.

Yes, the spec says that, but I think experience shows that applying this
rule to redundant xsi:schemaLocation attributes (or namespace/location
pairs) is unhelpful; and the spec generally gives implementations a lot of
flexibility in this area. Redundant xsi:schemaLocation attributes can easily
arise for example when a document is assembled using XInclude.

The rule has more-or-less disappeared in 1.1, I think, being replaced with a
general statement of its intent, namely that however you assemble the
schema, the effect must be as if you assembled the whole schema before
validating any part of the instance.

Michael Kay
http://www.saxonica.com/

> 
> The two instance documents addB162 and addB163 from the 
> schema test suite are defined as the following:
> ---------------------------------
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> 	  xsi:noNamespaceSchemaLocation="test93490_5.xsd" 	
> 	  xmlns:foo="foo"
> 	  xmlns:bar="bar">
> 
> 	<foo:elem1 xsi:schemaLocation="foo test93490_1.xsd" />
> 	<bar:elem2 xsi:schemaLocation="bar test93490_3.xsd" />
> 	<elem2 xsi:schemaLocation="bar test93490_4.xsd" /> </root>
> --------------------------------
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> 	  xsi:noNamespaceSchemaLocation="test93490_5.xsd" 	
> 	  xmlns:foo="foo"
> 	  xmlns:bar="bar">
> 
> 	<foo:elem1 xsi:schemaLocation="foo test93490_1.xsd" />
> 	<bar:elem2 xsi:schemaLocation="bar test93490_3.xsd" />
> 	<elem2>
> 		<a>
> 			<b>
> 				<c xsi:schemaLocation="foo 
> test93490_1.xsd" />
> 			</b>
> 		</a>
> 	</elem2>
> </root>
> --------------------------------
> While the first document is invalid according to the test 
> result and saxon validator, the second is valid. However they 
> seem to be quite similar to me. In both cases the a 
> schemaLocation declaration exists after it has been used 
> previously. In the first case 'bar' is reused and in the 
> second 'foo'. The only difference I see is, that the first 
> uses different locations (test93490_3.xsd vs. 
> test93490_4.xsd) while the second uses the same 
> (test93490_1.xsd). But is the location used as part of the 
> namespace here?!?
> 
> Ciao,
> Tobias
> 
Received on Friday, 6 February 2009 11:20:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:10 GMT