Re: [xsl] namespace generation in the output.

Subject: Re: [xsl] namespace generation in the output.
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Wed, 01 Jun 2005 16:40:29 +0100
On Tue, 2005-05-31 at 20:56 +0100, David Carlisle wrote:
> Dave, in your case the namespace seems to be statically known in the
> stylesheet so usually you don't need to do this copying trick, which is
> only normally needed if you need to generate the namespace uri
> dynamically. 
I may be wrong, but I think I do.
I'm generating a stylesheet, whose default output elements
need to be in the (as you say, fixed) namespace.


> 
> I can't really tell as the snippet you posted isn't well formed, 
Sorry.
http://cvs.sourceforge.net/viewcvs.py/docbook/xsl/xhtml/html2xhtml.xsl?
view=markup
look for the xsl:template match="xsl:stylesheet"

> but for
> example if you know what element xsl:copy is copying as you know which
> element is being matched, then you can simply replace xsl:copy with a
> literal result element that has the needed namespace decln.
> 
> When you do need to dynamically generate a namespace declaration xslt2
> has an xsl:namespace instruction that works like xsl:attribute, but for
> namespaces.

Thanks David.
(Please note folks, MK is being 'hard teacher' - go find out, DC is
being 'nice teacher' this is it :-)


I want:

<xsl:stylesheet ..... (standard stuff)
   xmlns="http://example.com";>

so I can write, in xslt 2.0,

<xsl:template match="....">
<xsl:element name="xsl:stylesheet" xsl:namespace="http://example.com";>

(No, I haven't tried it. docbook isn't xslt 2.0 friendly... yet)


regards DaveP

Current Thread