xsl-list
[Top] [All Lists]

Re: [xsl] Transforming xml with any namespace

2009-11-25 10:03:49
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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--