OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   RE: Namespace prefix question

[ Lists Home | Date Index | Thread Index ]
  • From: Kevin Williams <Kevin.Williams@ultraprise.com>
  • To: "'XML-DEV@xml.org'" <XML-DEV@xml.org>
  • Date: Thu, 3 Feb 2000 15:04:30 -0500


> This is actually more of a confirmation than a question:  Can I use the
> namespace prefix more than once in an XML document, pointing to different
> namespaces?  Like the following:
> <hi:element xmlns:hi="http://www.sernaferna.com">
>   <hi:element2 xmlns:hi="http://www.blah.com"/>
> </hi:element>

>From the "Namespaces in XML" recommendation:

5.1 Namespace Scoping

The namespace declaration is considered to apply to the element where it is
specified and to all elements within the content of that element, unless
overridden by another namespace declaration with the same NSAttName part...

So basically this means that in your example, all of the "hi:element"
element would have the "hi" namespace defined to be "www.sernaferna.com"
with the exception of the "hi:element2" element, which would have the "hi"
namespace defined to be "www.blah.com". This means that in this example:

<hi:element xmlns:hi="http://www.sernaferna.com">
  <hi:element2 xmlns:hi="http://www.blah.com"/>

the "hi:element3" element would be in the "www.sernaferna.com" namespace.

Hope this helps -

Kevin Williams (kwilliams@ultraprise.com)
Co-author, _Professional XML_ (Wrox Press)


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS