This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]