Re: [xsl] Deleting textnode

Subject: Re: [xsl] Deleting textnode
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 23 Apr 2004 10:36:18 +0100
Hi Animesh,

> I want to delete a text node.
>
> Suppose the XML format is something like:
> <tr>
> Google search:
> <a>English</a>
> <a>English</a>
> <a>English</a>
> </td>
>
> and I want to delete "Gogole Search" text node.

Start off with an identity transformation:

<xsl:template match="node()|@*">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()" />
  </xsl:copy>
</xsl:template>

Then add a template that does nothing with text node children of <td>
elements:

<xsl:template match="td/text()" />

Alternatively, add a template that only applies templates to the
element children of the <td> element, rather than to all its child
nodes:

<xsl:template match="td">
  <xsl:copy>
    <xsl:apply-templates select="@*|*" />
  </xsl:copy>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread