Changeset 1976

Show
Ignore:
Timestamp:
11/24/08 15:03:17
Author:
johnsa
Message:

added search and replace template to util

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/deployment/resources/xsl/default/default/util.xsl

    r1974 r1976  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
     3 
     4  <!-- search and replace template taken from 
     5       http://www.biglist.com/lists/xsl-list/archives/200211/msg00337.html --> 
     6  <xsl:template name="replace"> 
     7    <xsl:param name="string" select="''"/> 
     8    <xsl:param name="pattern" select="''"/> 
     9    <xsl:param name="replacement" select="''"/> 
     10    <xsl:choose> 
     11      <xsl:when test="$pattern != '' and $string != '' and contains($string, $pattern)"> 
     12        <xsl:value-of select="substring-before($string, $pattern)"/> 
     13        <xsl:copy-of select="$replacement"/> 
     14        <xsl:call-template name="replace"> 
     15          <xsl:with-param name="string" select="substring-after($string, $pattern)"/> 
     16          <xsl:with-param name="pattern" select="$pattern"/> 
     17          <xsl:with-param name="replacement" select="$replacement"/> 
     18        </xsl:call-template> 
     19      </xsl:when> 
     20      <xsl:otherwise> 
     21        <xsl:value-of select="$string"/> 
     22      </xsl:otherwise> 
     23    </xsl:choose> 
     24  </xsl:template> 
     25 
    326  <!-- URL-encoding template Written by Mike J. Brown, mike@skew.org. 
    427       No license; use freely, but credit me if reproducing in print.