Re: passing intermediate result while recursively buil
Hi Paul, > Given a string, I need to create an element to represent each word > of that string. The created element is relatively complex, and when > creating the element for word 'i' I may need to go back and examine > the elements for words 1 thru (i - 1) -- with order being important. > But at the end of it all, I'll need those newly created elements and > in the order they were created. Is that of any help? And please, if > my explanation leaves something to be desired, feel free to ask for > clarification. It sounds to me like a two-pass solution would be best here. First split up the string into words to create a simple node set of 'word' elements (or something), and then do stuff with that node set to create the elements that you actually want. That way you only have to do a result-tree-fragment-to-node-set conversion once, and can concentrate on each task independently. You need a simple tokenizing template to split the string into words: try Dimitre's in the FXSL library, or the one at http://www.exslt.org/str/functions/tokenize/str.tokenize.xsl if you want something fairly generic, or roll your own. Then do something like: <xsl:variable name="words"> <xsl:call-template name="tokenize"> <xsl:with-param name="string" select="$string" /> </xsl:call-template> </xsl:variable> <xsl:apply-templates select="exsl:node-set($words)/*" /> and have a template that matches the 'word' elements you've generated and does all the stuff (which might involve inspecting the 'word' element's preceding 'word' siblings). Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format