xsl-list
[Top] [All Lists]

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

2002-09-24 07:47:15
[ Peter Lavender]

Text handling like this is always (imho) a little confusing.  The 
simple answer is to use xsl:apply-templates as this will 
hit all the 
child
text() nodes, not just the first(ala value-of).
 
It is very confusing.

While apply-templates works as you said, the problem i have 
is that I want to remove the chars (), hence I tried value-of


You can remove them during the processing by translate(text(),"()","
").
I noticed that your original poset used substring-after() (I think it
was).  Both substring-after() and substring-before() return nothing if
the specified string is not present, so when you use them (not here),
you need to handle that possibility

As a good-practice rule, you should always use apply-templates over 
value-of (where possible) for a number of reasons, with the biggest 
probably being that template match=text() gets called.

I'm reluctant to purchase a book as a reference as I 
understand that somethings are not set in concrete yet.

XSLT 1.0 and XPath 1.0 are final and stable.  Get Mike Kay's book XSLT
Programmer's Reference (2nd ed.) and Jeni Tennison's book "XSLT on the
Edge' if you need really good books on XSLT.  They are well worth the
money.


Cheers,

Tom P

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