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

RE: Composition by extension in namespaced schema

From: Michael Kay <mike@saxonica.com>
Date: Fri, 14 Mar 2008 19:22:23 -0000
To: "'Gavin Kistner'" <phrogz@mac.com>, <xmlschema-dev@w3.org>
Message-ID: <024001c88608$bb9d55d0$6401a8c0@turtle>

> I need to use a targetNamespace (or is it an xmlns?) in my 
> schema so that I can validate other files without having to 
> add noNamespaceSchemaLocation to those files. Can someone 
> help me understand the core issue here, and (especially) how 
> to modify the file to accomplish the goal?
> 
> Thanks! Test case follows:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> targetNamespace="http://www.foo.com/">
>   <xs:complexType name="mammal" />
>   <xs:element name="dog">
>     <xs:complexType><xs:complexContent>
>     	<xs:extension base="mammal" />
>     </xs:complexContent></xs:complexType>
>   </xs:element>
> </xs:schema>
> 

The type is in a namespace, so the reference to it needs to be prefixed:

> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
> targetNamespace="http://www.foo.com/"
  xmlns:tgt="http://www.foo.com/">
>   <xs:complexType name="mammal" />
>   <xs:element name="dog">
>     <xs:complexType><xs:complexContent>
>     	<xs:extension base="tgt:mammal" />
>     </xs:complexContent></xs:complexType>
>   </xs:element>
> </xs:schema>

Michael Kay
http://www.saxonica.com/
Received on Friday, 14 March 2008 19:23:04 GMT

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