[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] junit test... for xslt2?


Subject: Re: [xsl] junit test... for xslt2?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Sat, 6 Mar 2010 09:41:30 +0000

> <!-- Integer compare -->
>  <xsl:function name="d:int-cmp" as="xs:boolean">
>    <xsl:param name="n1" as="xs:integer"/>
>    <xsl:param name="n2" as="xs:integer"/>
>    <xsl:choose>
>      <xsl:when test="$n1 = $n2">
>        <xsl:value-of select="true()"/>
>      </xsl:when>
>      <xsl:otherwise>
>        <xsl:value-of select="false()"/>
>      </xsl:otherwise>
>    </xsl:choose>
>  </xsl:function>

Out of interest, why would you want to use a function... what does
d:int-cmp($int1, $int2) give you over "$int1 eq $int2" ?

That aside, it's also worth using xsl:sequence rather than value-of to
return an atomic, to avoid the text node creation and atomisation.
And the choose can be compacted down to xsl:sequence select="$n1 eq
$n2".


--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/


Current Thread