Re: Invalid per cvc-complex-type.1.3: undeclared attribute {None}:use

Hi Edwin,

> If you don't use a targetNamespace, none of your Elements or
> Attributes should be in a namespace, however at the moment your
> Elements and Attributes are defined in the XMLSchema namespace.

I absolutely agree with your recommendation that you use a prefix for
the XML Schema namespace when dealing with a schema with no target
namespace.

Just a very small correction: the problem is not that the elements and
attributes you declare get put in the XML Schema namespace; if your
schema doesn't have a target namespace then the elements and
attributes are put in no namespace. Rather, the problem is that you
can't then *refer* to the elements and attributes you declare (or the
types you define) because the (unprefixed) qualified names that you
need to use to refer to them will be resolved using the default
namespace declaration, and hence all refer to
elements/attributes/types in the XML Schema namespace.

So, for example, the following is absolutely fine, because it doesn't
contain any references; both the <A> and <B> elements are placed in no
namespace:

<schema xmlns="http://www.w3.org/2001/XMLSchema">
  <element name="A">
    <complexType>
      <all>
        <element name="B" />
      </all>
    </complexType>
  </element>
</schema>

The following is problematic because the reference ref="B" will be
resolved based on the default XML Schema namespace, and no element
called <B> from the XML Schema namespace is present in the schema:

<schema xmlns="http://www.w3.org/2001/XMLSchema">
  <element name="A">
    <complexType>
      <all>
        <element ref="B"/>
      </all>
    </complexType>
  </element>
  <element name="B"/>
</schema>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Saturday, 25 October 2003 17:16:10 UTC