Re: [xsl] Can an element have 2 namespaces?

Subject: Re: [xsl] Can an element have 2 namespaces?
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Tue, 10 Nov 2009 08:32:47 +0100
On Mon, Nov 9, 2009 at 11:47 PM, cert21 <cert21@xxxxxxx> wrote:
> I am having trouble parsing this rss 1.0 feed
> The reason is that it appears that there are 2 different namespaces declared
> in the root document
>
> This is how the document starts:
>
> <?xml version="1.0" encoding="utf-8"?>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
> xmlns:dc="http://purl.org/dc/elements/1.1/";
> xmlns:sy="http://purl.org/rss/1.0/modules/syndication/";
> xmlns:admin="http://webns.net/mvcb/"; xmlns="http://purl.org/rss/1.0/";>
>

This root element defines the namespace prefixes rdf, dc, sy, admin and a
default namespace (http://purl.org/rss/1.0). Starting with this
element and ending
with the corresponding closing tag and inherited by all child elements
(except (1)),
any element or attribute name prefixed with one of these prefixes is in the
corresponding namespace associated with the URI, and an element without a prefix
is in the default namespace, whereas attributes without a prefix are in the
namespace of the tag of the element they belong to.

(1) Prefixes may be redefined in an inner element.

> The parser (in php, a DOMDocument class) reports the namespace to be
>
> http://www.w3.org/1999/02/22-rdf-syntax-ns#
>
> but why then they declared another namespace with
> xmlns="http://purl.org/rss/1.0/";
>
> Is it even a valid way to declare 2 namespaces together like this?
>

Only prefixes are declared, and a namespace for tags with only a local part.

> Anyway, which one is considered to be the correct one?
>

I think all of these questions are answered by my explanation. The root
element of a document is frequently used for declaring prefixes for
all namespaces that may appear, and possibly, a default namespace.

-W

Current Thread