Re: [xsl] Filtering child text nodes by node name

Subject: Re: [xsl] Filtering child text nodes by node name
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Fri, 23 Feb 2007 13:21:57 +0530
On 2/23/07, Anderson, Paul <Paul.Anderson@xxxxxxxxxxxxx> wrote:
<xsl:template match="title>
  <xsl:element name="topic-title">
     <xsl:for-each select=".//text()[not(ancestor::indexterm)]">
          <xsl:value-of select="."/>
     </xsl:for-each>
  </xsl:element>
</xsl:template>

I am glad my suggestion helped.


You could improve the readability a bit, by changing your code to following:

<topic-title>
  <xsl:for-each select=".//text()[not(ancestor::indexterm)]">
    <xsl:value-of select="."/>
  </xsl:for-each>
</topic-title>

xsl:element is usually used, when the element name is constructed
dynamically (sometimes based on some calculation).

--
Regards,
Mukul Gandhi

Current Thread