Re: [xsl] empty namespace added on elements E.g. <h4 xmlns="">

Subject: Re: [xsl] empty namespace added on elements E.g. <h4 xmlns="">
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Tue, 12 Jan 2010 13:42:55 +0100
Robby Pelssers wrote:
Ok... so I made a little change to the last xslt (see below) in my
cocoon pipeline which adds the xhtml namespace on xsl:stylesheet level.

The suggestion was to put
xmlns="http://www.w3.org/1999/XSL/Transform";
on the xsl:stylesheet element in the stylesheet that wants to create XHTML elements like 'html' or 'h4'.


In the stylesheet posted now you simply copy elements from the input to the output so putting the namespace declaration there does not change anything as it has no effect on copied elements, only on literal result elements created in the stylesheet and on elements created newly with xsl:element.



<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns="http://www.w3.org/1999/xhtml";>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<!-- copy all nodes and attributes which are not processed by one of
available templates -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="escapeHtml">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>


</xsl:stylesheet>

If you want to add a namespace to elements then you can't copy them, you will need to transform them.


--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread