W3C home > Mailing lists > Public > www-xsl-fo@w3.org > June 2001

Re: replacing cdata in nodes q.

From: John E. Simpson <simpson@polaris.net>
Date: Fri, 01 Jun 2001 14:10:34 -0400
Message-ID: <3B17DA9A.1040504@polaris.net>
To: Kerin Cosford <Kerin.Cosford@current-drugs.com>
CC: "W3 Xsl List (E-mail)" <www-xsl-fo@w3.org>
Kerin Cosford wrote:

> I'm writing a XSL sheet to process a large volume of XML files into 
> HTML. Every XML file has a node ("Summary") which contains a large block 
> of text. Within that text, there are various reference numbers (these 
> are scientific documents) in the format [1234567]. What I need to do is 
> have each occurance of the ref. number wrapped in a <a 
> href="1234567"></a> in the resulting HTML. Unfortunately I can't search 
> for a certain string of digits, as the reference numbers are not always 
> 7 characters long - so what I need to do is have a template which looks 
> for the square brackets, and returns what is held inside them to the 
> result tree like so: [<a href="1234567">1234567</a>].

It's not exactly the same problem, but I think a solution from the XSL 
FAQ is adaptable to your case. See:
    http://www.dpawson.co.uk/xsl/N7240.html#d44e34285
The key is a recursive named template which loops through the text node 
in question. Ugly as sin, and I don't know how performance is, but it 
works :). You might consider doing a one-time transformation of all the 
raw source documents to true markup (rather than the mixed 
markup/square-brackets thing you've got now), and then just going 
forward from there.
=================================================================
John E. Simpson          | "I installed a skylight in my
http://www.flixml.org    | apartment... The people who live above
XML Q&A: www.xml.com     | me are furious!" (Steven Wright)
Received on Friday, 1 June 2001 14:10:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:08 GMT