[xsl] Re: uses for strSplit-to-Words2 was RE: Re: How to process a list ?

Subject: [xsl] Re: uses for strSplit-to-Words2 was RE: Re: How to process a list ?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 8 Mar 2002 07:24:47 -0800 (PST)
"Bryan Rasmussen" <bry at itnisk dot com> wrote:

> Dimitre wrote:
> >Use strSplit-to-Words2.xsl from the FXSL xslt functional programming
> >library.
> 
> I was just thinking that strSplit might enable something I've thought

> of before but could never quite get my head around, which we might 
> call double-splitting, that is to say having a list of values that 
> are split in two(or more ways), example of css values should clarify 
> meaning.
> <div style="background-color:buttonface;border-bottom:black 2px
> solid;border-right:black 1px solid; font-family:verdana;
> font-size:largest;"></div>
> 
> I have sometimes come across scenarios where it would be useful to 
> split the values in @style into seperate elements for the property 
> names and values, have always had gut feeling that doing so in xslt 
> would hurt my brain, although I've written plenty of variations on 
> classic string splitting templates.
> it seems that if one saved each split at the ; to a nodeset, then use
> substring-before, substring-after on that nodeset at the : you could 
> do something like this, slight trepidation about processing power 
> used, although I don't think of this as online stuff, rather a 
> datamining thing.
> 
> Am curious if others using the FXSL library find this a reasonable
> suggestion.

Line splitting is an example of "double splitting". Or you may pass to
the tokeniser a user-supplied function, that given the current token 
performs its own, different tokenization on it.

When this problem is generalised (e.g. the maximum nesting level cannot
be known in advance), we'll definitely need something more powerful
than regular expressions.

Jeni has been asking for yacc-like functionality to be provided in
XPath 2.0.

Also DavidC gave an example from his work, which needed the power of a
CFG parser and could not be dealt with using just regular expressions.

It seems quite probable that such features will not be provided in
future versions of XPath.

Parser toolkits have been successfully developed in a functional
programming language [1], [2], and it's possible to produce such tools
in pure XSLT 1.0 with the help of a functional programming library.

Cheers,
Dimitre Novatchev.

References:

1. Happy, The Parser Generator for Haskell
http://www.haskell.org/happy/

2. Fast, Error Repairing Parser Combinators 
http://www.cs.uu.nl/groups/ST/Software/UU_Parsing/







__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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


Current Thread