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

RE: local unqualified element names and default namespaces

  • From: "Michael Kay" <mike@s...>
  • To: "'Pete Cordell'" <petexmldev@t...>,"'XML Developers List'" <xml-dev@l...>
  • Date: Sun, 12 Nov 2006 09:35:30 -0000

RE:  local unqualified element names and default namespaces
> If I define an unqualified local element such as 'name' in:

My first question would be *why* you would want to use this option?
> 
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>         targetNamespace="http://www.abc.com" 
> xmlns="http://www.abc.com"
>         elementFormDefault="unqualified">
> 
>     <xsd:element name="MyAddress" type="AddressType"/>
> 
>     <xsd:complexType name="AddressType">
>         <xsd:sequence>
>             <xsd:element name="name" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> 
> </xsd:schema>
> 
> 
> Then, if I have the following instance:
> 
> <MyAddress xmlns="http://www.abc.com">
>     <name>Pete</name>
> </MyAddress>
> 
> when deciding what to validate 'name' against, is it treated 
> as if it is {no namespace}:name, {http://www.abc.com}:name 
> (in which case validation will
> fail) 

My understanding is that <name> is required to be in no namespace, and
therefore this instance is not valid.

or something else?
> 
> Going a bit further... if (validated by another schema) I have:
> 
> <MyDetails xmlns="http://www.abc.com">
>     <ans:MyAddress xmlns:ans=http://www.abc.com/addr>
>         <name>Pete</name>
>     </ans:MyAddress>
> </MyDetails>
> 
> Is name's full name {no namespace}:name (due to being defined 
> as unqualified), {http://www.abc.com}:name (due to the 
> default namespace being http://www.abc.com), or 
> {http://www.abc.com/addr}:name (due to being local to ans:MyAddress)?
> 

The element in your instance is in namespace http://www.abc.com/, under the
rules of XML Namespaces. This isn't affected by the schema. The schema says
that you can only have a {}name element here, so this instance is not valid.

Michael Kay
http://www.saxonica.com/



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.