[xsl] Re: Was Tokenizing

Subject: [xsl] Re: Was Tokenizing
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 15 Apr 2002 05:42:14 -0700 (PDT)
> But that's what you asked for in the first place...
> 
> Okay, back to the point, XPath and XQuery offer functions you may
> use as well, namely xf:translate() and xf:normalize-space
> 
> If your source string is not too complex, and already is sort of
> well-structured, as it
> is if you use StringTokenizer to split the string,  _and_ your
> processor does support the basic string functions, you may use it as
> well, in combination with any of the string normalization functions
> to remove additional characters not needed for the tokenization.
> 
> e.g. your string contains
> 
>     "User Michael, Nachname Müller, Status Geek, ..."
> 
> and you want to tokenize this to
> 
>     "User Michael Nachname Müller Status Geek"
> 
> you may use the translate function to replace all occurences of ","
> with " "
> 
> translate($string, ",", " ")
> 
> and then pass this directly to the recursive template I presented in
> the earlier

Download FXSL and have a look at strSplit-to-Words2.xsl, or search Dave
Pawson's XSLT-FAQ for "functional tokenizer", ... or just look here:

http://sources.redhat.com/ml/xsl-list/2001-11/msg00901.html

The functional tokenizer accepts a set of delimiters (e.g ' ', CR, NL,
TAB, ';', ',',... etc.), thus achieving much greater flexibility than
other algorithms, having either a hard-wired delimiter-character or
accepting as parameter just a single character.

Cheers,
Dimitre Novatchev.




__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

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


Current Thread