users@jaxb.java.net

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

From: Philip, Tim <Tim_Philip_at_intuit.com>
Date: Thu, 23 Oct 2003 09:48:10 -0700

This was really helpful, Kevin. Thanks.

My confusion was that I thought if I defined the default namespace on my
schema element that it would apply to everything. But apparently that is
only the case if I set elementFormDefault="qualified".

Are there other consequences of moving all of the (inner) local definitions
into the same namespaces as the schema? Why wouldn't you want to do that?

I ask because I was given a schema that explicitly set
elementFormDefault="unqualified" and I'm curious as to why they would do
that. Clearly they wanted to emphasis that they weren't taking the default,
they wanted it to be that way.


Tim.

> -----Original Message-----
> From: Kevin Jones [mailto:kevinj_at_develop.com]
> Sent: Thursday, October 23, 2003 9:00 AM
> To: users_at_jaxb.dev.java.net
> Subject: RE: Re: xmlns="" in direct child element.
>
>
> "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
>
>


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