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

Re: How namespaces are unique???

Subject: Re: How namespaces are unique???
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Thu, 30 May 2002 05:36:39 -0700
xmlns prefix unique
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 30 May 2002 05:05, Mailer Mailer wrote:
> both had namespace definition like this:
>
> xmlns:calp="http://url1.com/meta/calp"
>
> xmlns:calp-"http://url2.com/bit/calbit"
>
>
> Can anyone explain me how namespace is resolving the
> conflict, when the these prefix names are same???

As I'm sure many people will tell you, the prefix **doesn't matter at all**.  
It is what comes after the prefix that counts.  In fact, if you do 
xmlns="...", you can have a namespace without a prefix at all.

The following elements are all completely equivilant:

<foo xmlns="bar"/>
<prefix:foo xmlns:prefix="bar"/>
<xx:foo xmlns:xx="bar"/>

And the following elements are all totally different:

<prefix:foo xmlns:prefix="bar"/>
<prefix:foo xmlns:prefix="zap"/>
<foo xmlns="zoip"/>
<foo xmlns="xyz"/>

The prefix is merely a shorthand way of telling the XML processor which URI is 
associated with the element.  The processor uses whatever xmlns declaration 
for a given prefix is in scope.  So even if two elements with the same 
prefixes exist in a single document, they can have different namespaces and 
therefore be totally different elements:

<document>
  <element xmlns:prefix="bar">
    <prefix:foo/>
  </element>
  <element xmlns:prefix="zap">
    <!-- this <foo> is different from the first -->
    <prefix:foo/>
  </element>
</document>

The only thing that matters is the URI that is the value of the xmlns 
declaration.  If the two URIs are not *exactly* the same, then any elements 
using the prefixes associated with the different URIs will be in different 
namespaces.

The fact that most URIs take the form of "http://foo.com/..." does not mean 
that the server at foo.com is contacted at all.  Think of the URI as merely a 
string of characters that has nothing to do with any actual internet 
protocol.  Even if www.foo.com and www2.foo.com resolve to the same server, 
"http://www.foo.com/namespace" and "http://www2.foo.com/namespace" will be 
different namespaces.

BTW, have you ever heard of google?  I find it hard to believe that this 
question has not already been answered thousands of times :)

- -- 
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE89hzcNSZCJx7tYycRAsqNAJ9+ei3vVjVEwrvuTNmW7DF0iZrN7wCfZECt
qVX2qsxrTo4bJRIv1UfNcRE=
=EfE8
-----END PGP SIGNATURE-----


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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
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.