RE: Composition by extension in namespaced schema

> 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 UTC