OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
Trouble with repeated call-templates
This page's ID:
23004
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
So I have the following two named templates. What I am trying to do is highlight seperate terms from the search. The problem is that while highlightThisTerm works when called by itself, when I call it from within highlightSearchTerms the span tag disappears. (this part) [code] <span class="highlightTerm"> <xsl:value-of select="$term" disable-output-escaping="yes" /> </span> [/code] Now I still get the value of $term and if I do something like [code] hi <span class="highlightTerm">here <xsl:value-of select="$term" disable-output-escaping="yes" />doh </span> test [/code] Then all the text shows up but still no span tag. Anyone have any ideas why? [code] <xsl:template name="highlightSearchTerms"> <xsl:param name="haystack" /> <xsl:param name="i" select="1" /> <xsl:variable name="newhaystack"> <xsl:choose> <xsl:when test="$i <= count(/*/Time_Window/Term)"> <xsl:call-template name="highlightThisTerm"> <xsl:with-param name="haystack" select="$haystack" /> <xsl:with-param name="needle" select="/*/Time_Window/Term" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$haystack" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="$i < count(/*/Time_Window/Term)"> <xsl:call-template name="highlightSearchTerms"> <xsl:with-param name="haystack" select="$newhaystack" /> <xsl:with-param name="i" select="$i + 1" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$newhaystack" disable-output-escaping="yes"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="highlightThisTerm"> <xsl:param name="haystack" /> <xsl:param name="needle" /> <xsl:variable name="before-length"> <xsl:value-of select="string-length(substring-before( translate($haystack,$UPPERCASE,$LOWERCASE) , translate($needle, $UPPERCASE,$LOWERCASE )))" /> </xsl:variable> <xsl:variable name="before"> <xsl:value-of select="substring($haystack, 1, $before-length)" /> </xsl:variable> <xsl:variable name="startPos"> <xsl:value-of select="string-length( $before ) + 1" /> </xsl:variable> <xsl:variable name="endPos"> <xsl:value-of select="$before-length + 1 + string-length( $needle )" /> </xsl:variable> <xsl:variable name="term"> <xsl:value-of select="substring($haystack, $startPos, string-length($needle))" /> </xsl:variable> <xsl:variable name="after"> <xsl:value-of select="substring($haystack, $endPos )" /> </xsl:variable> <xsl:choose> <xsl:when test="contains(translate($haystack,$UPPERCASE,$LOWERCASE) , translate($needle, $UPPERCASE,$LOWERCASE ) )"> <xsl:value-of select="$before" /> <span class="highlightTerm"> <xsl:value-of select="$term" disable-output-escaping="yes" /> </span> <xsl:choose> <xsl:when test="contains(translate($after,$UPPERCASE,$LOWERCASE) , translate($needle, $UPPERCASE,$LOWERCASE ) )"> <xsl:call-template name="highlightThisTerm"> <xsl:with-param name="haystack" select="$after" /> <xsl:with-param name="needle" select="normalize-space(/*/Search_Term)" /> <!-- <xsl:with-param name="terms" select="normalize-space(/*/Search_Term)" /> --> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$after" /> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="$haystack" /> </xsl:otherwise> </xsl:choose> </xsl:template> [/code] [img]http://www.bitdamaged.com/graphics/bitsig.gif[/img] .:[ Never resist a perfect moment ]:.
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »