Friday, 26 September 2014

XSLT postive number to negative



How to check number (decimal or whole number ) in XSLT .I want to convert it to Negative if it is positive number otherwise i have to keep as it is . I verfied in google and all i see is negative number to positive number,using XSLT version as 1.0. Please give some samples.


Take below samples:



<Books>
<Book>
<Name>NC</Name>
<Price>100.50</Price>
</Book>
</Books>


<Books>
<Book>
<Name>NC</Name>
<Price>-200</Price>
</Book>
</Books>


Negative number to Positive:



<xsl:value-of select="Price * (Price >= 0) - Price * not(Price >= 0)" />


I want convert positive number to Negative and if number already Negative , i have to keep it as it is.


Regards, Chaitu


No comments:

Post a Comment