Skip to content

Instantly share code, notes, and snippets.

@cergey-obr
Created November 6, 2014 09:46
Show Gist options
  • Save cergey-obr/c04ff4a69eeab7dea136 to your computer and use it in GitHub Desktop.
Save cergey-obr/c04ff4a69eeab7dea136 to your computer and use it in GitHub Desktop.
Склонение после числительных
<xsl:template name="declension">
<xsl:param name="number" />
<xsl:param name="f0" />
<xsl:param name="f1" />
<xsl:param name="f2" />
<xsl:variable name="absnum">
<xsl:choose>
<xsl:when test="$number &lt; 0"><xsl:value-of select="0 - $number" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$number" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="($absnum mod 10) = 1 and ($absnum mod 100) != 11">
<xsl:value-of select="$f0"/>
</xsl:when>
<xsl:when test="(($absnum mod 10) &gt;= 2) and (($absnum mod 10) &lt;= 4) and (($absnum mod 100 &lt; 10) or ($absnum mod 100 &gt;= 20))">
<xsl:value-of select="$f1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$f2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment