Reputation: 86925
https://xsltfiddle.liberty-development.net/pPJ8LV9
<person age="18"/>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
<xsl:template match="person">
<xsl:variable name="given" select="12" />
<xs:if test="(@age < $given)">
<xsl:value-of select="(@age < $given)"/>
<xsl:text> </xsl:text>
<xsl:text>SHOULD NOT PRING</xsl:text>
</xs:if>
</xsl:template>
</xsl:stylesheet>
Result:
false
SHOULD NOT PRING
Why on earth does it print, when the condition obviously evaluates to false
?
Upvotes: 0
Views: 102
Reputation: 117165
You need to change:
xs:if
to:
xsl:if
What you have now is not a condition, but a literal result element. You can see this if you change the output method to xml
.
P.S. Not sure why you need the parentheses.
Upvotes: 1