To format all the Decimal fields to European Amount formatting

Hi all,

I have an XML which has Decimal field which need to formatted to European Currency format.

<?xml version="1.0" encoding="UTF-16"?>
     <tssArticleNumber>Item Number1234</tssArticleNumber>
     <compoundCodeBucket>N123 & others</compoundCodeBucket>
     <qualityIndexBucket>Std Quality</qualityIndexBucket>
     <weightGroupBucket>BT 123.1234 and 12345.1234</weightGroupBucket>

Please help me guys i have other Xslt which i used, which will help you to know the format i am looking for

//this has been taken from a Microsoft knowledgebase aricle and strips out the
//namespaces from an XML message using a style sheet
XslTransform :=  XslTransform.XslTransform;
XMLStyleSheet := XMLStyleSheet.XmlDocument;
'<?xml version="1.0" encoding="UTF-8"?>'+
'<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:fo="" xmlns:msxml="urn:schemas-microsoft-com:xslt">'+
'<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="UTF-8" indent="yes"/>' +
'<xsl:template match="@*|node()">'+
'<xsl:apply-templates select="@*|node()"/>'+
'<xsl:template match="'+OldNode+'">'+
'<xsl:variable name="oldNode" select="'+OldNode+'"/>' +
'<xsl:variable name="newNodeXml">' +
'<xsl:element name="'+NewNode+'">' +
'<xsl:copy-of select="$oldNode/@*|node()"/>' +
'<xsl:copy-of select="$oldNode/child::*"/>' +
'<xsl:copy-of select="$oldNode/@*"/>' +
'</xsl:element>' +
'</xsl:variable>' +
'<xsl:copy-of select="msxml:node-set($newNodeXml)"/>' +
'</xsl:template>' +
writer := writer.StringWriter();
XslTransform.Transform(Source, nullXsltArgumentList, writer);
Destination := Destination.XmlDocument;

//'<xsl:with-param name="text" select="." />' +

Any Help? :frowning:

Define European format first

Thank you for your response. I hope i can make the things more clear to you. The European format is “,” for Decimal separator and “.” for Digit Grouping. Whereas US have the reverse. For example 1,000.156 in US and 1.000,156 for Europe. The problem here is i need to use it multiple times for the Fields. I want an XSLT which change the format for all the decimal fields at once. I hope you got my point

That’s what I thought. But that’s not true for all European coutries. UK is Europe and uses dot for decimals and commas for thousands.

I assume that you want something like this

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
  <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
  <xsl:template match="/">
    <xsl:value-of select="format-number(26825.8, '#.###,00', 'euro')"/>

Now, this is generic code, I haven’t applied it to your existing XSL but you get the idea

Thanks Molona,

I have created an XSLT as follows

<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:fo="" xmlns:msxml="urn:schemas-microsoft-com:xslt">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
        <xsl:apply-templates select="@*|node()"/>
<xsl:decimal-format name="eu" decimal-separator=',' grouping-separator='.' />
<xsl:template match="*[not(*) and number()=number()]">
        <xsl:value-of select="format-number(., '#.##0,##########', 'eu')" />

But i am getting an error in my application(working fine in The error is

Microsoft Dynamics NAV
A call to System.Xml.Xsl.XslTransform.Load failed with this message: Expression must evaluate to a node-set.

If you’re using Microsoft, maybe this example could be a bit better for you

The issue was with the Dotnet Automation Variable. The error was not meaning ful. The automation variable was System.Xml.Xsl.XslTransform

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.