RE: [xsl] split a string of expression into elements

Subject: RE: [xsl] split a string of expression into elements
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 23 Feb 2004 00:13:14 -0000
You need to understand that what you are doing here is parsing the
string according to a grammar. The first stage is lexical analysis -
splitting the string into a sequence of tokens. You can probably do that
with the tokenize() function in XPath 2.0. The second stage is syntax
analysis. How difficult that is depends on the complexity of the
grammar. You can do it using the standard top-down syntax analysis
algorithms, which can be implemented in XSLT just as well as in any
other language, but you first need a good understanding of these
algorithms, which you can get from a compiler textbook, and you then
need a good understanding of recursive functional programming in XSLT,
which is a rather esoteric language for this kind of problem.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ha Nguyen
> Sent: 22 February 2004 19:17
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] split a string of expression into elements
> 
> 
> Hello !
> 
> I'd like to split a string of expressions into several 
> elements. For example: <string>
>         x := b + c   
> </string>
> 
> transform to sth like
> 
> <assignment>
>        <left> x </left> 
>        <right>  
>              <operator> plus </operator>     
>              <aleft> b </aleft>
>              <aright> c </aright>
>        </right>
> </assignment>
> 
> The expression may be not simple like that, meaning
> that it contains more operations x:= b + c - d ... 
> 
> Can you give me some directions how to transform like
> that ? Can xslt match the string according to a
> regular expression and give the substring? 
> 
> Thanks for your attention.
> ha.
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail SpamGuard - Read only the mail you want. 
http://antispam.yahoo.com/tools

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


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


Current Thread