Re: [xsl] Transforming an XML document where the content isn't in a special tag

Subject: Re: [xsl] Transforming an XML document where the content isn't in a special tag
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Wed, 17 Aug 2005 11:44:59 +0530
Sorry, I was wrong.

The correct XSLT 1.0 stylesheet is -

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="html" indent="yes"/>

<xsl:template match="/root">
    <html>
      <head>
        <title/>
      </head>
      <body>
        <xsl:apply-templates select="header" />
      </body>
    </html>
</xsl:template>

<xsl:template match="header">
    <h1><xsl:value-of select="." /></h1>
    <xsl:call-template name="printTextNode">
      <xsl:with-param name="nodelist"
select="following-sibling::node()[1] | following-sibling::node()[2]"
/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="printTextNode">
    <xsl:param name="nodelist" />
    <p>
      <xsl:for-each select="$nodelist">
        <xsl:choose>
          <xsl:when test="name() = 'a'">
            <xsl:copy-of select="." />
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="." />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
    </p>
</xsl:template>

</xsl:stylesheet>

Hope this helps,

Regards,
Mukul

Current Thread