RE: [xsl] How do I capture the text "around" a node?

Subject: RE: [xsl] How do I capture the text "around" a node?
From: "Passin,Thomas B. (Tom)" <tpassin@xxxxxxxxxxxx>
Date: Tue, 24 Sep 2002 11:05:44 -0400
[Peter Lavender]
 
> It is very confusing.
>

It can be, especially while you are getting used to the way xslt works.
 
> While apply-templates works as you said, the problem i have 
> is that I want to remove the chars (), hence I tried value-of
> 

Here is a really easy and readable way to do your task, based on
apply-templates as several people have suggested already:

<xsl:variable name='text'>
	<xsl:apply-templates select='text'/>
</xsl:variable>

<xsl:value-of select='translate($text,")(","")'/>

The apply-templates brings in all the text, including text in any child
nodes even though you may not know the names of the child elements, and
even if some of the children are nested within each other.  This happens
because there is no template to match a "text" element, so the processor
applies the built-in default templates, which get the text.

The translate() function replaces the '(' and ')' characters with
nothing, which gets rid of them.

Cheers,

Tom P


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


Current Thread