Re: [xsl] Is it possible to set the default namespace with a dynamically-generated namespace uri?

Subject: Re: [xsl] Is it possible to set the default namespace with a dynamically-generated namespace uri?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Sat, 13 Mar 2010 00:01:03 +0000
On 12/03/2010 23:44, Dimitre Novatchev wrote:
It seems to me that using<xsl:namespace>  it is not possible to
specify a default namespace.


it's possible to use xsl:namespace to produce a namespace node with no name which produces a default namespace declaration in the result tree
but xsl:namespace (whether with a Qname or empty string as the name attribute) never changes the namespace of nodes creted, just adds additional nodes.



so in



<a:b xmlns:a="b"> <xsl:namespace name="" select="'zzz'"/> <c/> </a:b>


then (assuming that there wasn't already a default namespace in scope)
xsl:namespace will indeed generate a default namespace binding but it doesn't change the namepsace of a:b 9as that;s already generated with the prefix and namespace b, an dit doesn't affect the namespace of c as
pputting a namespace node in the result tree doesn't affect the namespace context in the stylesheet, so you get



<a:b xmlns:a="b" xmlns="zzz"><c xmlns=""/></a:b>


which has xmlns="zzz" but the system adds xmlns="" to preserve the (no)namespace of c.

David

Current Thread