Namespaces

R

R.Georges

Hello,

I'm a little confused with namespaces and non qualified name :

If I write

<a xmlns:p="http://www.blabla.com">
<b/>
</a>

I should consider 'a' inside the 'http://www.blabla.com' namespace. Do I consider
too 'b' as a part of this namespace as their no default namespace ?

If yes what the interest of the xmlns attribute ?

Other point :

<a xmlns:p="http://www.blabla.com" xmlns="http://www.blibli.com">
<b/>
</a>

Do I consider 'a' and 'b' on the "http://www.blibli.com" namespace ?

If yes, what happened when writing :

<p:a xmlns:p="http://www.blabla.com" xmlns="http://www.blibli.com">
<b/>
</p:a>

Do I consider 'b' on the http://www.blibli.com namespace or http://www.blabla.com ?

Thanks in advances,

G.
 
R

Richard Tobin

I should consider 'a' inside the 'http://www.blabla.com'
namespace. Do I consider too 'b' as a part of this namespace as their
no default namespace ?

No, b is in no namespace.

(Some people - a few - write documents in which elements in no
namespace are interpreted according to the namespace of the enclosing
namespaced element, in the same way that most people make the
interpretation of no-namespace attributes depend on the element
they're attached to. But that's a matter of interpretation; as
far as the XML namespaces spec is concerned, such elements are not
in any namespace. XML schema's elementForm="unqualified" exists for
the benefit of these people.)
<a xmlns:p="http://www.blabla.com" xmlns="http://www.blibli.com">
<b/>
</a>

Do I consider 'a' and 'b' on the "http://www.blibli.com" namespace ?
Yes.

If yes, what happened when writing :

<p:a xmlns:p="http://www.blabla.com" xmlns="http://www.blibli.com">
<b/>
</p:a>

Do I consider 'b' on the http://www.blibli.com namespace or
http://www.blabla.com ?

a is in the blabla namespace and b is in the blibli namespace.

-- Richard
 
D

Dean Tiegs

No, b is in no namespace.

Note that in this example element "a" is also in no namespace. The
namespace declaration is only for elements prefixed with "p".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top