Re: [xsl] Transforming xml with any namespace

Subject: Re: [xsl] Transforming xml with any namespace
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 25 Nov 2009 16:03:22 +0100
Anders Viklund wrote:
Ok, changed to XSLT 2.0, but still the same problem...

XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">
<xsl:output method="text" />
<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>
<xsl:template match="*:Type1">
   <xsl:value-of select="local-name(.)"/> <xsl:text
disable-output-escaping="yes">=</xsl:text> <xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>

OUTPUT:
Type1=value1
Type1=value2
please dont print me

The main change you need is
<xsl:template match="text()"/>
to avoid having the default templates output all text nodes.
You will then also need to output white space explicitly where you want it e.g.
<xsl:template match="*:Type1">
<xsl:value-of select="local-name()"/>
<xsl:text>=</xsl:text>
<xsl:value-of select="."/>
<xsl:text>&#10;</xsl:text>
</xsl:template>
--


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

Current Thread