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

Re: [xsl] Recursive function referencing an XML file, best programming technique


Subject: Re: [xsl] Recursive function referencing an XML file, best programming technique
From: Liam R E Quin <liam@xxxxxx>
Date: Wed, 09 Jun 2010 12:17:38 -0400

On Tue, 2010-06-08 at 13:57 -0500, Mario Madunic wrote:
> This is more of a programming technique question than a how to.

Others have answered your question, but a couple of other thoughts...

> I'll be creating a recursive function in XSLT that will manipulate a
> tokenized string (on spaces), capitalize initial letter in each word
> and lower case the rest of the word.

Hmm, you can do this with analyze-string and avoid the recursion in most
cases - maybe you're using XSLT 1? You'd still need to write a
template/function to change the first character to its upper-case
equivalent. You can use upper-case() as a first approximation.

(One ought also to be able to do it with "replace" but we did not
include \u \U \l and \L support in the spec, alas.)

>  An issue arises for product names and acronyms, as the way they are
> spelt is quite specific. So I'll create a library XML file that will
> contain the correct spelling for these strings and do a check on each
> string.

If they are really strings, with no embedded elements (e.g. you are not
dealing with Japanese Ruby here, or fragments of mathematics), you can
use XSLT's key() mechanism to make the lookup reasonably fast.

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org


Current Thread
Keywords