Re: qname resolution question

Hi Taki,

> I am wondering if the following schema is valid or not. Both XSV and
> xerces passes validation with it.
>
> What is the namespace name for the "documentBody" qname below? Is it
> "http://www.w3.org/2001/XMLSchema", or is it none (as
> targetNamespace is not provided)?

The schema is not valid because the reference to the QName
'documentBody' is resolved using the default namespace, which is the
XML Schema namespace http://www.w3.org/2001/XMLSchema. The schema
validator looks for an element declaration for
{http://www.w3.org/2001/XMLSchema}documentBody, and finds none, and
should give an error (XSV, MSV and Xerces-C++ all give an error).

To create a schema for no namespace in which you reference types and
element/attribute declarations, you need to use a prefix for the XML
Schema namespace:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >

<xs:element name = "envelope">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref = "documentBody"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name = "documentBody" type="anyType"/>
  
</xs:schema>

Cheers,

Jeni

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

Received on Tuesday, 1 January 2002 04:52:25 UTC