[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] local unqualified element names and default namespaces
- From: "Pete Cordell" <petexmldev@tech-know-ware.com>
- To: "'XML Developers List'" <xml-dev@lists.xml.org>
- Date: Mon, 13 Nov 2006 19:38:00 -0000
Ooops - suffering from multiple personality disorder!... For the benefit of
the list (or otherwise)...
-------------------
Many thanks Michael.
As to why, someone asked me, and I started with great confidence,... which
then eroded away!
I know it's not a favoured pattern, but for data binding I actually think it
makes a lot of sense.
If you then use Venetian blind (I think that's the right one - mainly global
types) design, you don't need any more namespace declarations, which roughly
mirrors program code design. e.g.:
<tns:MyDetails xmlns:tns="http://www.abc.com">
<MyAddress>
<name>Pete</name>
</MyAddress>
<MyCompany>
<name>ABC</name>
</MyCompany>
</tns:MyDetails>
Maps to MyDetails.MyAddress.name and MyDetails.MyCompany.name as opposed to
something like MyDetails.MyAddress.Address::name etc.
I appreciate it's more problematic for documents though, and especially
document manipulation where globally unique names make life easier.
Thanks again,
Pete.
----- Original Message -----
From: "Michael Kay" <mike@saxonica.com>
To: "'Pete Cordell'" <petexmldev@tech-know-ware.com>; "'XML Developers
List'" <xml-dev@lists.xml.org>
Sent: Sunday, November 12, 2006 9:35 AM
Subject: RE: [xml-dev] 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/
>
>
> _______________________________________________________________________
>
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
>
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]