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 https://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 <!-- Pass this stylesheet a lang parameter in order to select a language. --> 11 <xsl:param name="lang" /> 12 13 <xsl:output method="text" /> 14 15 <xsl:template match="/"> 16 <xsl:apply-templates select="//thetip[lang($lang)]" /> 17 </xsl:template> 18 19 <xsl:template match="thetip"> 20 * <xsl:apply-templates /> 21 </xsl:template> 22 23 <xsl:template match="tt"> 24 <xsl:text>{{{</xsl:text> 25 <xsl:apply-templates /> 26 <xsl:text>}}}</xsl:text> 27 </xsl:template> 28 29 <!-- This sucks, but I don't seem to get xsl:strip-space to work. --> 30 <xsl:template match="text()"> 31 <xsl:call-template name="search-and-replace"> 32 <xsl:with-param name="input" select="." /> 33 <xsl:with-param name="search-string" select="'
 '" /> 34 <xsl:with-param name="replace-string" select="' '" /> 35 </xsl:call-template> 36 </xsl:template> 37 38 <xsl:template name="search-and-replace"> 39 <xsl:param name="input" /> 40 <xsl:param name="search-string" /> 41 <xsl:param name="replace-string" /> 42 <xsl:choose> 43 <xsl:when test="$search-string and contains($input, $search-string)"> 44 <xsl:value-of select="substring-before($input, $search-string)" /> 45 <xsl:value-of select="$replace-string" /> 46 <xsl:call-template name="search-and-replace"> 47 <xsl:with-param name="input" 48 select="substring-after($input, $search-string)" /> 49 <xsl:with-param name="search-string" select="$search-string" /> 50 <xsl:with-param name="replace-string" select="$replace-string" /> 51 </xsl:call-template> 52 </xsl:when> 53 <xsl:otherwise> 54 <xsl:value-of select="$input" /> 55 </xsl:otherwise> 56 </xsl:choose> 57 </xsl:template> 58 59</xsl:stylesheet> 60