Re: reference to element, elementFormDefault unqualified

Hi Oliver,

The schema/@elementFormDefault an element/@form apply to local elements 
and not to global elements. Global elements are always defined in the 
schema target namespace.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Oliver Kusche wrote:
> 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:33:02 UTC