<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:pmrr="http://schemas.pertmaster.com/2006/PMRiskRegister" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="my-utility-function">

	<xsl:param name="m_nPlanDecPlaces">2</xsl:param>
	<xsl:param name="m_strThousandsSeparator">t</xsl:param>
	<xsl:param name="m_strDecimalSeparator">d</xsl:param>
	<xsl:param name="m_strCurrency">$</xsl:param>
	<xsl:param name="m_strSuffCurrency"></xsl:param>

<msxsl:script language="JScript" implements-prefix="user"><![CDATA[

		
		// number formatting function
			// copyright Stephen Chapman 24th March 2006, 10th February 2007
			// permission to use this function is granted provided
			// that this copyright notice is retained intact
			
			//We can easily select different formatting by changing the values in the second 
			//through eighth parameters. The second parameter is the number of decimal places 
			//that the number should have. If the number contains more decimal places than 
			//required it will be rounded to the nearest number with that number of decimal places. 
			//If it has fewer decimal places than specified zeroes will be added to the end. 

			//The third parameter is the thousands separator. In our example we used a space 
			//but a comma or period may be what is required for your location. 

			//The fourth parameter is the decimal point. Either a period or comma is normal here. 

			//The fifth and sixth parameters are used for monetary values and one or other of 
			//them will contain the currency symbol when required. If your location uses a 
			//currency symbol hard against the left of numbers then place that symbol by itself 
			//in the fifth parameter eg. '$'. If you normally have a space after the currency 
			//symbol then add it after the symbol in this '$ '. If your currency symbol comes 
			//after the amount instead of before then place it in the sixth parameter instead 
			//of the fifth parameter. 



			function MyFormatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) 
			{
				var x = Math.round(num * Math.pow(10,dec));
				if (x >= 0) 
					n1=n2='';
					
				var y = (''+Math.abs(x)).split('');
				var z = y.length - dec; 
				if (z<0) 
					z--; 
					
				for(var i = z; i < 0; i++) 
					y.unshift('0');
					if (dec == 0)
						y.splice(z, 0, ''); 
					else
						y.splice(z, 0, pnt); 
					
				while (z > 3) 
				{
					z-=3; 
					y.splice(z,0,thou);
				}
				
				var r = curr1+n1+y.join('')+n2+curr2;return r;
			}]]>
		</msxsl:script>

	<xsl:template match="/">
		

		<xsl:variable name="strValue">444234463434.34434</xsl:variable>

		<xsl:value-of select="user:MyFormatNumber(number($strValue),number($m_nPlanDecPlaces),string($m_strThousandsSeparator),string($m_strDecimalSeparator),string($m_strCurrency),string($m_strSuffCurrency),'-','')"/>

	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="test.xml" htmlbaseurl="" outputurl="" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator=""/></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->