Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSL mod Operation gives wrong result due to large value

 
Dhaval Hansaliya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I want to perform modulus operation on the XSL variable having value, more than XSD:unsignedLong datatype. (For Eg: 2100041810000023014509 mod 97)
My current implementation is:



But, <result> tag displays wrong result.
According to me, the wrong result is due to the large value.

Is there any other way to perform mod operation in XSL?

Thanks In Advance,
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You omitted to say what the answer was according to you and what the answer was according to XSLT and why you were right and XSLT was wrong.
 
Dhaval Hansaliya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks for replay...

Actual result for the mod operation of 2100041810000023014509 digit (2100041810000023014509 mod 97) = 32
But, when i assign this value to variable (Lets say sum) and perform same operation ($sum mod 97), i am getting the result = 86
This wrong output is because of modulo operation on the integer number, which is larger than the data type range.

Now, I have written templates in XSL file which divides the input number in small segments and perform modulo operations on each segments.


Still, update me, if there is an easier method available in the XSL to perform same operation.

thanks,
-Dhaval
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I get 32 from my Windows calculator too.

I didn't want to say that XSLT was "wrong" to come up with something else because I remember some complaints from way back when XSLT was first designed. My recollection was that people who tried to write transformers in a language other than Java claimed they were at a disadvantage because the spec said (essentially) that XSLT had to do arithmetic exactly as Java did it.

But now I can't find any evidence of that on the web. However, I'm pretty sure your theory about why XSLT gets the wrong answer for that calculation is right. Unfortunately I don't have any advice for you about how to get the right answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic