Re: elements in a namespace

Subject: Re: elements in a namespace
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Mon, 07 Jun 1999 01:24:26 +0100

This was very educational - thanks. You've corrected something I had not
only misunderstood but just posted to this newgroup as an answer...

Mike Brown wrote:
> Steve Dahl was quite helpful. Here is a summary of what he told me in
> private email. Hopefully my interpretation is correct:
> 1. Once a namespace is defined for an element, you must identify that
> element by the combination of its namespace prefix and the element name;
> simply referring to the element name by itself means "element with this name
> and with no namespace".
> Example:
> If element <Department> contains <Employee> contains <FirstName>, and all
> are in the namespace assigned to prefix "mine", a variable could be bound to
> the value of the content of <FirstName> like this:
> <xsl:variable name="Some_First_Name"
> expr="/mine:Department/mine:Employee/mine:FirstName"/>
> 2. There's no way to define a default namespace to make the above any
> easier.

In the stylesheet, "Expression evaluation occurs with respect to a
context, which consists of: [...] the set of namespace declarations in
scope for the expression" but "the default namespace (as declared by
xmlns) is not part of this set"(see in other words,
the spec says XSLT expressions can use namespace prefixes in the normal
way but not namespace defaults. So the example I just posted (using a
namespace default in the stylesheet) may work in XT but appears to be

> 3. The binding of an element to a namespace doesn't affect its attributes.
> Attributes only need to be referenced with a prefix if they are specifically
> bound to a namespace themselves. Example:
> <!-- attribute 'src' of element <img>, where <img>
>      is in namespace bound to prefix 'xhtml' -->
> <value-of select="xhtml:img/@src"/>
> <!-- same, but with 'src' in namespace bound to prefix
>      'myAttributes' -->
> <value-of select="xhtml:img/@myAttributes:src"/>
The namespaces rec says "Note that default namespaces do not apply
directly to attributes." So source attributes get processed in the same
way as XSLT expression attributes. Simpler...

Francis Norton.

Air Rage - a "flight *and* fight" reaction?

 XSL-List info and archive:

Current Thread