Re: [xsl] Ignoring Child Nodes using XPath

Subject: Re: [xsl] Ignoring Child Nodes using XPath
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 26 Mar 2001 09:54:09 +0100
Hi Ciaran,

> Is there a way in which I can select a node ignoring the child nodes
> as in the following example:

Selecting a node just points to the node, tells the processor that it
should be dealt with.  The processor only does what you tell it to do,
so if you want the child nodes to be ignored, you just have to *not*
tell it to do anything with them.

So for example, you could use the following template to copy the p
element and its attributes but ignore its children:

<xsl:template match="p">
   <xsl:copy>
      <xsl:copy-of select="@*" />
   </xsl:copy>
</xsl:template>

Note no templates are applied to or copies made of the child nodes of
the p element.  You don't tell the processor to do anything with them,
so it does nothing, effectively ignoring them.

I hope that helps,

Jeni

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



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread