Skip to main content
Solved

XML templater number format issue

  • August 25, 2025
  • 2 replies
  • 32 views

eric_armitage
Contributor
Forum|alt.badge.img+10

Hi

I have an attribute value derived from an Excel sheet. The input attribute name is “Vægt”. FME data type is number(20,2). An example value for a feature is “2.95”. I’m trying to retrieve this value using the xml templater using <Cell><Data Type="Number">{fme:get-attribute("Vægt")}</Data></Cell> 

 

 

But the output value in the xml is 2.9500000000000002

 

Could anyone explain why this is happening and suggest a fix? I have tried attribute rounding and changing the input Data Type but nothing seems to work.

 

Thanks

Best answer by david_r

The reason why: https://support.safe.com/hc/en-us/articles/25407633363981-Floating-Point-Precision-and-String-Formatting-in-FME

Workaround: 

Example:

<tag>{fn:round(xs:double(fme:get-attribute("Vægt")), 2)}</tag>
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • Best Answer
  • August 25, 2025

The reason why: https://support.safe.com/hc/en-us/articles/25407633363981-Floating-Point-Precision-and-String-Formatting-in-FME

Workaround: 

Example:

<tag>{fn:round(xs:double(fme:get-attribute("Vægt")), 2)}</tag>

eric_armitage
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • August 25, 2025

Thanks David that worked!