Created
August 1, 2008 15:16
-
-
Save kana/3631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<!-- | |
Usage: xsltproc cho45-problem.xslt cho45-problem.xslt | |
Problem: http://twitter.com/cho45/statuses/874759595 | |
From "3.4 Booleans" | |
in "XML Path Language (XPath) Version 1.0 W3C Recommendation 16 November 1999" | |
<http://www.w3.org/TR/1999/REC-xpath-19991116>, | |
When neither object to be compared is a node-set and the operator is <=, <, | |
>= or >, then the objects are compared by converting both objects to numbers | |
and comparing the numbers according to IEEE 754. | |
--> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="text" encoding="UTF-8"/> | |
<xsl:variable name="NL" select="'
'"/> | |
<xsl:template match="/"> | |
<xsl:call-template name="test"> | |
<xsl:with-param name="a" select="1"/> | |
<xsl:with-param name="b" select="2"/> | |
</xsl:call-template> | |
<xsl:call-template name="test"> | |
<xsl:with-param name="a" select="'1'"/> | |
<xsl:with-param name="b" select="'2'"/> | |
</xsl:call-template> | |
<xsl:call-template name="test"> | |
<xsl:with-param name="a" select="'1 1'"/> | |
<xsl:with-param name="b" select="'2 2'"/> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="test"> | |
<xsl:param name="a"/> | |
<xsl:param name="b"/> | |
<xsl:value-of select="$NL"/> | |
<xsl:if test="$a = $b"> | |
<xsl:value-of select="$a"/> | |
<xsl:text> = </xsl:text> | |
<xsl:value-of select="$b"/> | |
<xsl:value-of select="$NL"/> | |
</xsl:if> | |
<xsl:if test="$a != $b"> | |
<xsl:value-of select="$a"/> | |
<xsl:text> != </xsl:text> | |
<xsl:value-of select="$b"/> | |
<xsl:value-of select="$NL"/> | |
</xsl:if> | |
<xsl:if test="$a < $b"> | |
<xsl:value-of select="$a"/> | |
<xsl:text> < </xsl:text> | |
<xsl:value-of select="$b"/> | |
<xsl:value-of select="$NL"/> | |
</xsl:if> | |
<xsl:if test="$a <= $b"> | |
<xsl:value-of select="$a"/> | |
<xsl:text> <= </xsl:text> | |
<xsl:value-of select="$b"/> | |
<xsl:value-of select="$NL"/> | |
</xsl:if> | |
<xsl:if test="$a > $b"> | |
<xsl:value-of select="$a"/> | |
<xsl:text> > </xsl:text> | |
<xsl:value-of select="$b"/> | |
<xsl:value-of select="$NL"/> | |
</xsl:if> | |
<xsl:if test="$a >= $b"> | |
<xsl:value-of select="$a"/> | |
<xsl:text> >= </xsl:text> | |
<xsl:value-of select="$b"/> | |
<xsl:value-of select="$NL"/> | |
</xsl:if> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment