Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
53
Task/FizzBuzz/XSLT/fizzbuzz-1.xslt
Normal file
53
Task/FizzBuzz/XSLT/fizzbuzz-1.xslt
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:output method="text" encoding="utf-8"/>
|
||||
|
||||
<!-- Outputs a line for a single FizzBuzz iteration. -->
|
||||
<xsl:template name="fizzbuzz-single">
|
||||
<xsl:param name="n"/>
|
||||
|
||||
<!-- $s will be "", "Fizz", "Buzz", or "FizzBuzz". -->
|
||||
<xsl:variable name="s">
|
||||
<xsl:if test="$n mod 3 = 0">Fizz</xsl:if>
|
||||
<xsl:if test="$n mod 5 = 0">Buzz</xsl:if>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- Output $s. If $s is blank, also output $n. -->
|
||||
<xsl:value-of select="$s"/>
|
||||
<xsl:if test="$s = ''">
|
||||
<xsl:value-of select="$n"/>
|
||||
</xsl:if>
|
||||
|
||||
<!-- End line. -->
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Calls fizzbuzz-single over each value in a range. -->
|
||||
<xsl:template name="fizzbuzz-range">
|
||||
<!-- Default parameters: From 1 through 100 -->
|
||||
<xsl:param name="startAt" select="1"/>
|
||||
<xsl:param name="endAt" select="$startAt + 99"/>
|
||||
|
||||
<!-- Simulate a loop with tail recursion. -->
|
||||
|
||||
<!-- Loop condition -->
|
||||
<xsl:if test="$startAt <= $endAt">
|
||||
<!-- Loop body -->
|
||||
<xsl:call-template name="fizzbuzz-single">
|
||||
<xsl:with-param name="n" select="$startAt"/>
|
||||
</xsl:call-template>
|
||||
|
||||
<!-- Increment counter, repeat -->
|
||||
<xsl:call-template name="fizzbuzz-range">
|
||||
<xsl:with-param name="startAt" select="$startAt + 1"/>
|
||||
<xsl:with-param name="endAt" select="$endAt"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Main procedure -->
|
||||
<xsl:template match="/">
|
||||
<!-- Default parameters are used -->
|
||||
<xsl:call-template name="fizzbuzz-range"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
33
Task/FizzBuzz/XSLT/fizzbuzz-2.xslt
Normal file
33
Task/FizzBuzz/XSLT/fizzbuzz-2.xslt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:exsl="http://exslt.org/common"
|
||||
exclude-result-prefixes="xsl exsl">
|
||||
<xsl:output method="text"/>
|
||||
|
||||
<xsl:template name="FizzBuzz" match="/">
|
||||
<xsl:param name="n" select="1" />
|
||||
<xsl:variable name="_">
|
||||
<_><xsl:value-of select="$n" /></_>
|
||||
</xsl:variable>
|
||||
<xsl:apply-templates select="exsl:node-set($_)/_" />
|
||||
<xsl:if test="$n < 100">
|
||||
<xsl:call-template name="FizzBuzz">
|
||||
<xsl:with-param name="n" select="$n + 1" />
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="_[. mod 3 = 0]">Fizz
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="_[. mod 5 = 0]">Buzz
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="_[. mod 15 = 0]" priority="1">FizzBuzz
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="_">
|
||||
<xsl:value-of select="concat(.,'
')" />
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
10
Task/FizzBuzz/XSLT/fizzbuzz-3.xslt
Normal file
10
Task/FizzBuzz/XSLT/fizzbuzz-3.xslt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="text"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:value-of separator="
" select="
|
||||
for $n in 1 to 100 return
|
||||
concat('fizz'[not($n mod 3)], 'buzz'[not($n mod 5)], $n[$n mod 15 = (1,2,4,7,8,11,13,14)])"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Loading…
Add table
Add a link
Reference in a new issue