xsl-list
[Top] [All Lists]

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

2005-08-16 23:14:59
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

--~------------------------------------------------------------------
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>
--~--