[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] analyze-string and child nodes


Subject: Re: [xsl] analyze-string and child nodes
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 12 May 2010 00:16:34 +0100

On 11/05/2010 21:19, Terry Ofner wrote:
Thank you David. The template works perfectly. I only needed to add one ] near the end of the match line.
The take-away message for me: when one wants to apply-templates with regular expressions,
use replace() instead of analyze-string. Is that an accurate summary of the approach?

Not really, the main point is to apply the regexp (whether replace or analyze-string to the text nodes rather than to the entire element or mixed content.


You need to use analyze-string rather than replace if you need to generate element nodes as part of the replacement text as replace() is a atring-to-string function.

In this case as you were just extracting the initial digit sequence and dropping it in an element I could use replace (at the cost of having to apply the regexp twice once to extract the first bit and again to extract the second.) If the regexp were more complicated an alternative would have been to use analyze-string to split up the text node and to return a sequence and then to pass that sequence to subsequent teplates.

David


Current Thread