home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 February / CMCD0205.ISO / Linux / gimp-2.2.0.tar.gz / gimp-2.2.0.tar / gimp-2.2.0 / tips / fortunes.xsl < prev    next >
Extensible Markup Language  |  2004-08-26  |  2KB  |  58 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <!--  This simple XSL transformation creates a text version from
  4.       gimp-tips.xml.in which can then be used to seed
  5.       http://wiki.gimp.org/gimp/FortuneCookies in the GIMP Wiki.  -->
  6.  
  7. <xsl:stylesheet version="1.0"
  8.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  9.  
  10.   <xsl:output method="text" />
  11.  
  12.   <xsl:template match="/">
  13.     <xsl:apply-templates select="//_thetip" />
  14.   </xsl:template>
  15.  
  16.   <xsl:template match="_thetip">
  17.  * <xsl:apply-templates />
  18.   </xsl:template>
  19.  
  20.   <xsl:template match="tt">
  21.     <xsl:text>{{{</xsl:text>
  22.     <xsl:apply-templates />
  23.     <xsl:text>}}}</xsl:text>
  24.   </xsl:template>
  25.  
  26.   <!--  this sucks
  27.     but I don't seem to get xsl:strip-space to work with xsltproc  -->
  28.   <xsl:template match="text()">
  29.     <xsl:call-template name="search-and-replace">
  30.       <xsl:with-param name="input" select="." />
  31.       <xsl:with-param name="search-string"  select="'     '" />
  32.       <xsl:with-param name="replace-string" select="' '" />
  33.     </xsl:call-template>
  34.   </xsl:template>   
  35.  
  36.   <xsl:template name="search-and-replace">
  37.     <xsl:param name="input" />
  38.     <xsl:param name="search-string" />
  39.     <xsl:param name="replace-string" />
  40.     <xsl:choose>
  41.       <xsl:when test="$search-string and contains($input, $search-string)">
  42.     <xsl:value-of select="substring-before($input, $search-string)" />
  43.     <xsl:value-of select="$replace-string" />
  44.     <xsl:call-template name="search-and-replace">
  45.       <xsl:with-param name="input"
  46.               select="substring-after($input, $search-string)" />
  47.       <xsl:with-param name="search-string" select="$search-string" />
  48.       <xsl:with-param name="replace-string" select="$replace-string" />
  49.     </xsl:call-template>
  50.       </xsl:when>
  51.       <xsl:otherwise>
  52.     <xsl:value-of select="$input" />
  53.       </xsl:otherwise>
  54.     </xsl:choose>
  55.   </xsl:template>
  56.  
  57. </xsl:stylesheet>
  58.