[xsl] Re: code review

Subject: [xsl] Re: code review
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 20 Feb 2004 22:27:22 +0100
For ways to optimize global search and replace see:

"Two-stage recursive algorithms in XSLT"
http://www.topxml.com/xsl/articles/recurse/


Cheers,

Dimitre Novatchev
FXSL developer,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html



"Theresa Devine" <tdevine@xxxxxxxxxxxx> wrote in message
news:E532D1B0782C094C888974D23892BCC66CD3FF@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I was wondering if ya'll might review my xslt and see if there is a more
> efficient way of doing this transformation. The part I have questions
> about is the search and replace....
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>
> <xsl:param name="sycampusid"></xsl:param>
> <xsl:param name="schoolname"></xsl:param>
> <xsl:param name="accred"></xsl:param>
>
> <xsl:template match="/">
> <table>
> <xsl:apply-templates/>
> </table>
> </xsl:template>
>
> <xsl:template match="BodyText/Title">
> <xsl:if test="../@sycampusid=$sycampusid">
> <tr><td class="header">
> <xsl:value-of select="."/>
> </td></tr>
> </xsl:if>
> </xsl:template>
>
> <xsl:template match="BodyText/Paragraph">
> <tr><td class="bodyText">
> <xsl:if test="../@sycampusid=$sycampusid">
> <xsl:variable name="newstring2">
> <xsl:variable name="newstring">
> <xsl:call-template name="globalReplace">
> <xsl:with-param name="outputString" select="."/>
> <xsl:with-param name="target"
> select="'#schoolname#'"/>
> <xsl:with-param name="replacement"
> select="$schoolname"/>
> </xsl:call-template>
> </xsl:variable>
> <xsl:call-template name="globalReplace">
> <xsl:with-param name="outputString"
> select="$newstring"/>
> <xsl:with-param name="target"
> select="'#accred#'"/>
> <xsl:with-param name="replacement"
> select="$accred"/>
> </xsl:call-template>
> </xsl:variable>
> <xsl:call-template name="globalReplace">
> <xsl:with-param name="outputString"
> select="$newstring2"/>
> <xsl:with-param name="target"
> select="'&amp;quot'"/>
> <xsl:with-param name="replacement"
> select="'&amp;#8217'"/>
> </xsl:call-template>
> </xsl:if>
> </td></tr>
> </xsl:template>
>
> <xsl:template match="BodyText/Link">
> <xsl:if test="../@sycampusid=$sycampusid">
> <tr><td class="bodyText">
> <a><xsl:attribute
> name="class">bodytextlink</xsl:attribute><xsl:attribute
> name="href"><xsl:value-of
> select="./@linktarget"/></xsl:attribute><xsl:value-of
> select="."/></a><xsl:text>&#160;</xsl:text>
>
> <xsl:call-template name="globalReplace">
> <xsl:with-param name="outputString"
> select="./@linktext"/>
> <xsl:with-param name="target" select="'#schoolname#'"/>
> <xsl:with-param name="replacement"
> select="$schoolname"/>
> </xsl:call-template>
> </td></tr>
> </xsl:if>
> </xsl:template>
>
> <xsl:template name="globalReplace">
>   <xsl:param name="outputString"/>
>   <xsl:param name="target"/>
>   <xsl:param name="replacement"/>
>   <xsl:choose>
>     <xsl:when test="contains($outputString,$target)">
>       <xsl:value-of
> select="concat(substring-before($outputString,$target), $replacement)"/>
>       <xsl:call-template name="globalReplace">
>         <xsl:with-param name="outputString"
> select="substring-after($outputString,$target)"/>
>         <xsl:with-param name="target" select="$target"/>
>         <xsl:with-param name="replacement" select="$replacement"/>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:value-of select="$outputString"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>  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