[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: passing intermediate result while recursively buil

Subject: Re: passing intermediate result while recursively building nodeset
From: "paul morgan" <pmorg@xxxxxxxxx>
Date: Thu, 09 May 2002 14:47:36 -0700
intermediate result of 2002
Hi Jeni,

I apologize in the delay in following up on your response (thanks) to my question -- I don't get sick often, but when I do it's a doozy.

I believe I understand your solution, but to my adled brain it appears as if I'm merely substituting a node set for a string, and I'll still confused as to how to access the nodes that I'm creating along the way.

I'm also afraid I've done a poor job of explaining what I'm after, so let me try again ...

Following your suggestion, I take my string (say, "NO BRAIN LEFT") and tokenize it:

    <token>NO</token>
    <token>BRAIN</token>
    <token>LEFT</token>

and then I have a template that matches "token".  Each matching of the "token" template results in the creation of a relatively complex element (say an "x" element).  But to complicate matters, the value of an "x" element can not be *solely* determined by looking at any (or all) of the "token" elements, its value is dependent upon the previously created "x" elements -- that is, when creating the i-th "x" element, I may need to look at the 1 thru (i - 1) "x" elements that were previously created.  In addition, order is important; for example, the "x" element which was created in response to matching "<token>BRAIN</token>" will be the second element in the final node set.


Now, using a suggestion from Michael Kay I can do this, but I was trying to come up with a way that was better than O(n^2) performance.  And I'm not tied to recursion if a technique using "for-each" will do a better job.

Am I making any sense?

Thanks,

Paul
 
--

On Fri, 3 May 2002 22:47:59   
 Jeni Tennison wrote:
>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
>
>



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.