users@jaxb.java.net

RE: Re: xmlns="" in direct child element.

From: Kevin Jones <kevinj_at_develop.com>
Date: Thu, 23 Oct 2003 17:00:02 +0100

"inheriting" was perhaps the wrong term here. Namespaces are said to be
in scope, the default namespace is in scope from where it is first
defined to all descendant elements unless a descendant element sets
xmlns="", this has the effect of "turning off" the default namespace and
putting the element into "no namespace" (modulo namespace prefixes).

In a schema you have two types of element definition, global and local.
Global elements are those defined as direct children of the schema
element, local elements are those defined as children of other schema
definitions, such as your example

<complexType name="RecType">
   <sequence>
        <!-- this is a 'local' element definition -->
        <element name="CKT_ID" type="string"/>
   </sequence>
   <attribute name="RECNAME" type="string"> fixed="REQUEST_DATA"/>
</complexType>

By *default* global elements are in the target namespace of the schema,
local elements are in "no namespace". Your schema's target namespace is
"http://www.mycom.com/CLIPIF" so all global elements in the schema that
are used in an XML instance document will be in this namespace, all
local element definitions will be in no namespace.

Using 'elementFormDefault' changes this behaviour.
elementFormDefault="unqualified" is the default setting for schema, if
you leave out elementFormDefault or you set
elementFormDefault="unqualified" you get the same behaviour. However if
you set elementFormDefault="qualified" every element from the schema
whether local or global will now be in the targetNamespace.

You can also set this value on individual elements within the schema
(form="[un]qualified").

So in your instance document

<!-- global element in targetNamespace -->
<TRANSACTION TRANNAME="TRANSACTION"
xmlns="http://www.myxmlnsdefinition">
    <!-- local element in no namespace -->
    <!-- but targetNamespace still in scope so have to set "no
namespace" -->
    <NAME xmlns="">ASSGN_SCAN_OPER</NAME>
    <!-- local element in no namespace -->
    <!-- but targetNamespace still in scope so have to set "no
namespace" -->
    <VERSION xmlns="">1</VERSION>
    <!-- local element in no namespace -->
    <!-- but targetNamespace still in scope so have to set "no
namespace" -->
    <RECORD RECNAME="REQUEST_DATA" xmlns="">
         <!-- local element in no namespace -->
        <!-- but targetNamespace not in scope so do not have to set "no
namespace" -->
        <CKT_ID>S 50/QQQQ/44440000/SC</CKT_ID>
        <TKT_ID>
            <TKTTypeId>10</TKTTypeId>
            <TKTTypeValue>tksValue</TKTTypeValue>
        </TKT_ID>
    </RECORD>
</TRANSACTION>


Hope that helps,

Kevin Jones
Developmentor
www.develop.com



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net