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

Recursively Processing Text Question

Subject: Recursively Processing Text Question
From: Matthew Broude <mbroude@xxxxx>
Date: Sun, 04 Dec 2005 03:04:15 -0500
matthew broude
Hello all -

I'm in the middle of a big project and I'm getting tripped up by something
that seems like it should be fairly simple....

I am working with an XML file of news stories that includes a list of
keywords to use as links, essentially in a format like:

<LINK>Term 1</LINK>
<LINK>Term 2</LINK>
<LINK>Term 3</LINK>

I am trying to recursively add links in around the first occurrence in
FULLTEXT of each keyword specified in the LINKs. Here's the XSL template
I've written so far:

<xsl:template name="TextLinker">
    <xsl:param name="LinkNum" select="count(LINK) + 1"/>
        <xsl:when test="$LinkNum > count(LINK)">
            <xsl:value-of select="FULLTEXT"/>
            <xsl:variable name="LinkedText">
                <xsl:call-template name="TextLinker">
                    <xsl:with-param name="LinkNum" select="$LinkNum + 1"/>
            <xsl:variable name="LinkText"><xsl:value-of
             <xsl:variable name="PreLinkText"
select="substring-before($LinkedText, $LinkText)"/>
             <xsl:variable name="PostLinkText"
select="substring-after($LinkedText, $LinkText)"/>
          <xsl:value-of select="$PreLinkText"/>
             <xsl:value-of select="$PostLinkText"/>

And I call that when I need it by using:

<xsl:call-template name="TextLinker">
<xsl:with-param name="LinkNum" select="1"/>

The end result is that I get back the FULLTEXT with the first LINK keyword
linked properly but with the remaining LINK keywords unchanged. Through
testing of this I know it's looping correctly, it's just seems to end up
returning the untreated FULLTEXT each recursion until it finally resolves
and deals just with LINK[1], thus why the first keyword is linked properly
but the others aren't.

I'm sure it must be something obvious I'm missing.

Please help!


Current Thread


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.
First Name
Last Name
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.