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

Re: code review

Subject: Re: code review
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Fri, 20 Feb 2004 22:27:22 +0100
code review template
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

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.