Re: [xsl] Problem using Math functions

Subject: Re: [xsl] Problem using Math functions
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 24 Jan 2006 14:45:49 GMT
> Is there any transformer property that i can set at the
> run time for setting the precision bounds?

No, XSLT1 mandates IEEE double.

Of course you can do the addition by hand, something like this (which
assumes the strings have the same length, you'd need to be a bit more
careful otherwise)

add.xml

     <employee>
          <Arg1>1000020000300004000950000</Arg1>
          <Arg2>0000000000000001000060000</Arg2>
     </employee>


add.xsl
xmlns:xs="http://www.w3.org/2001/XMLSchema";
version="1.0">

<xsl:template match="employee">
 <xsl:param name="a" select="Arg1"/>
 <xsl:param name="b" select="Arg2"/>
 <xsl:param name="c" select="0"/>
 <xsl:param name="t" select="''"/>
<xsl:choose>
  <xsl:when test="string($a)">
  <xsl:variable name="x" select="substring($a,string-length($a))+substring($b,string-length($b))+$c"/>
  <xsl:apply-templates select=".">
    <xsl:with-param name="a" select="substring($a,1,string-length($a)-1)"/>
    <xsl:with-param name="b" select="substring($b,1,string-length($b)-1)"/>
    <xsl:with-param name="c" select="floor($x div 10)"/>
    <xsl:with-param name="t" select="concat($x mod 10,$t)"/>
  </xsl:apply-templates>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="$t"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

 
</xsl:stylesheet>


 saxon add.xml add.xsl
<?xml version="1.0" encoding="utf-8"?>1000020000300005001010000

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread