[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: RE: 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
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: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.


Tom P

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.