1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
<?xml version="1.0"?>
<!-- bottles of beer by Cyrus Dolph May 16, 2000 -->
<!-- input template of form: <bottles>99</bottles> -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8"/>
<xsl:template name="bottles">
<xsl:param name="bottles"/>
<xsl:choose>
<xsl:when test="$bottles = 1">
<xsl:text>1 bottle</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select='concat ($bottles, " bottles")'/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="verse">
<xsl:param name="bottles"/>
<xsl:choose>
<xsl:when test="$bottles = 0">
<xsl:text>0 bottles of beer on the wall,
0 bottles of beer!
Go into town, buy a new round
Get some more bottles of beer on the wall!
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="bottles">
<xsl:with-param name="bottles" select="$bottles"/>
</xsl:call-template>
<xsl:text> of beer on the wall,
</xsl:text>
<xsl:call-template name="bottles">
<xsl:with-param name="bottles" select="$bottles"/>
</xsl:call-template>
<xsl:text> of beer!
Take one down, pass it around;
</xsl:text>
<xsl:call-template name="bottles">
<xsl:with-param name="bottles" select="$bottles - 1"/>
</xsl:call-template>
<xsl:text> of beer on the wall.
</xsl:text>
<xsl:call-template name="verse">
<xsl:with-param name="bottles" select="$bottles - 1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:call-template name="verse">
<xsl:with-param name="bottles" select="/bottles"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
|