XSLT Function Round

Rounds a number specified by user

NAMESPACE

xmlns:AS="http://schema.advantages.cz/AsapFunctions"

SYNTAX

string Round(decimal number, string origamRoundingId, string roundingPosition)

PARAMETERS

Name Description
number Number to be rounded.
origamRoundingId Rounding profile Id.
roundingPosition Position of rounding

EXAMPLE

This example rounds a number using a provided profile.
Source XML

<ROOT> 
    <test number="3.1415927" roundingId="0b58b6b8-5d68-42bd-bf23-c698a9c78cbf" positions="0.001" /> 
</ROOT>

Stylesheet

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:AS="http://schema.advantages.cz/AsapFunctions" 
    xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date"> 
   <xsl:template match="ROOT">
		<ROOT>
			<xsl:apply-templates select="test"/>
		</ROOT>
	</xsl:template>

	<xsl:template match="test">
		<test test="{AS:Round(@number, @roundingId, @positions)}"/>
	</xsl:template>
</xsl:stylesheet>

Result

<ROOT>
  <test test="3.142">
  </test>
</ROOT>