RE: [xsl] adding namespaces to result nodes

Subject: RE: [xsl] adding namespaces to result nodes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 8 Apr 2005 12:26:20 +0100
>          Iam taking the text of an element in the input file 
> and making it
> into an element. The element in question is named 'slideshow' and it
> doesn't have a prefix. You say
> "the processor may put the element in the default namespace, or it may
> invent a prefix"
> Does this mean the processor Iam using (xalan) is adding the 
> prefix whereas
> another processor may not.

Yes. If you write

<xsl:element name="slideshow" namespace="http://some.uri/"/>

Then the processor may generate

<ns0:slideshow xmlns:ns0="http://some.uri/"/>

or

<slideshow xmlns="http://some.uri/"/>

- it's implementation-defined. 

XSLT 2.0 has rules that make the generation of namespace prefixes slightly
more predictable, though there are still cases where the processor is
allowed to dream one up.

> 
> Iam not tied to any processor and I may opt for another 
> processor if this
> is the case other things permitting.

It's not a good idea to choose a processor because it happens to do what you
want, when the language says that the behavior of your stylesheet is
unpredictable. Better to ask yourself some questions about the requirement
you are trying to satisfy - why do namespace prefixes matter so much?

Michael Kay
http://www.saxonica.com/

Current Thread