[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: junit test... for xslt2?
On 06/03/10 08:17, Andrew Welch wrote:
Hi Dave,This works for what I'm doing. Display is down to the 'driver' which includes this code. Just returns boolean pass/fail. <!-- 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> <!-- Double compare --> <xsl:function name="d:double-cmp" as="xs:boolean"> <xsl:param name="n1" as="xs:double"/> <xsl:param name="n2" as="xs:double"/> <xsl:param name="tolerance" as="xs:double"/> <xsl:choose> <xsl:when test="abs($n1 - $n2) <= $tolerance"> <xsl:value-of select="true()"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose> </xsl:function> <!-- item() compare --> <xsl:function name="d:item-cmp" as="xs:boolean"> <xsl:param name="n1" as="item()"/> <xsl:param name="n2" as="item()"/> <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>
<xsl:function name="d:numeric-cmp" as="xs:boolean"> <xsl:param name="n1" as="xs:double"/> <xsl:param name="n2" as="xs:integer"/> <xsl:param name="tolerance" as="xs:double"/> <xsl:variable name="n2d" select="number($n2)" as="xs:double"/> <xsl:choose> <xsl:when test="abs($n1 - $n2d) <= $tolerance"> <xsl:value-of select="true()"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose> </xsl:function>
regards -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|