[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

reference to element, elementFormDefault unqualified

From: Oliver Kusche <oli@trip.net>
Date: Thu, 13 Apr 2006 17:01:01 +0200
Message-ID: <20060413170101.yvaq0rug008wgkgs@webmail.qaccess.net>
To: xmlschema-dev@w3.org
invalid or unqualified reference

Hi,

I'm experiencing a behavior with a referenced element that I don't quite
understand. I have a schema for common datatypes that defines an own
targetNamespace. Within, I have a global element declared that actually is used
by a complexType  definition in the same schema, but that can also be
independently used by an importing schema.

Then I have a main schema that imports the common schema and defines two
elements, one of the complex type and one referencing the global element.

To hide namespaces from instance documents, elementFormDefault is set to
unqualified.

common schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="nscommon" xmlns="nscommon" elementFormDefault="unqualified">
    <xs:complexType name="LinkType">
        <xs:sequence>
            <xs:element name="sub1" type="xs:string"/>
            <xs:element ref="sub2"></xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="sub2" type="xs:string"/>
</xs:schema>

main schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="nsprocess" xmlns="nsprocess" xmlns:common="nscommon"
xmlns:process="nsprocess" elementFormDefault="unqualified">
    <xs:import namespace="nscommon" schemaLocation="common.xsd"/>

    <xs:element name="root" type="process:rootType"/>

    <xs:complexType name="rootType">
        <xs:sequence>
            <xs:element name="link" type="common:LinkType"/>
            <xs:element ref="common:sub2"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

Now the following instance document is invalid, since the processor seems to
expect a namespace declaration (nscommon) for the sub2 elements.

instance document:

<process:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:process="nsprocess"
    xsi:schemaLocation="nsprocess process.xsd">
    <link>
        <sub1/>
        <sub2/>
    </link>

    <sub2/>

</process:root>

However, when I set elementFormDefault to qualified in both schemas and qualify
all elements in the instance document with the appropriate namespace, the
document is valid.

Now why is this thing behaving differently, and is there a way of making such a
reference with elementFormDefault unqualified at all?

cheers,
Oli

----------------------------------------------------------------
Received on Thursday, 13 April 2006 15:10:33 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.