Composition by extension in namespaced schema

The appended test case shows a simple schema that fails to validate (using oXygen/Xerces) when the targetNamespace is declared for the file. If I remove the targetNamespace, the file validates and works just fine.

I see that there are 'suggestions' on how to fix this, but I don't know exactly what to do. (Just adding an empty <xs:import> doesn't fix anything. It changes the error to say that the name can't be resolved.)

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>

<!--
  SystemID: E:\foo.xsd
  Location: 6:36
  Description: src-resolve.4.1: Error resolving component 'mammal'. It was detected that 'mammal' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/E:/foo.xsd'. If 'mammal' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'mammal' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/E:/foo.xsd'.
  URL: http://www.w3.org/TR/xmlschema-1/#src-resolve
-->

Received on Friday, 14 March 2008 19:02:58 UTC