logo       

Re: XML Schema + Namespace Issues: msg#00066

Subject: Re: XML Schema + Namespace Issues
/Sean McCauliff/:

I have a schema file where I define two complex types and one of the complex types defines an element with the type of the other complex type. When I write an instance file the enclosed element is in an empty namespace instead of being defined in the name space of the type or of the enclosing element. See instance_a.xml and schema_a.xsd below.
[...]
If I change the schema so that the bType is defined as an element instead. Then "b" is not in the http://eslug.net namespace.

Element "b" _is_ in the "http://eslug.net"; namespace - all top-level/global components have the 'targetNamespace' of the schema they are defined in.

schema_b.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
          targetNamespace="http://eslug.net";
          xmlns="http://eslug.net";
>
 <xsd:element name="b">
   <xsd:complexType >
    <xsd:attribute name="anotherattr" type="xsd:string" use="required" />
   </xsd:complexType>
 </xsd:element>
[...]
I would rather use schema a, but elements of "bType" only seem to show
up in the empty namespace forcing me to use schema_b.

Is this a bug or there some misunderstanding with how namespaces are
assigned to compexTypes in xml schema?

You may take a look at "3 Advanced Concepts I: Namespaces, Schemas & Qualification" <http://www.w3.org/TR/xmlschema-0/#NS>, "3.1 Target Namespaces & Unqualified Locals", "3.2 Qualified Locals". So as far as I understand you just need to set |elementFormDefault="qualified"| on the <schema> element.

You may also see how the {target namespace} of an element declaration (for example) is determined from its representation <http://www.w3.org/TR/xmlschema-1/#element-element>:

If the <element> element information item has <schema> as its parent, the corresponding schema component is as follows:

{target namespace} The ·actual value· of the targetNamespace [attribute] of the parent <schema> element information item, or ·absent· if there is none.
[...]

otherwise if the <element> element information item has <complexType> or <group> as an ancestor and the ref [attribute] is absent...

{target namespace} If form is present and its ·actual value· is qualified, or if form is absent and the ·actual value· of elementFormDefault on the <schema> ancestor is qualified, then the ·actual value· of the targetNamespace [attribute] of the parent <schema> element information item, or ·absent· if there is none, otherwise ·absent·.

--
Stanimir


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe