Skip to main content
Solved

Coordinate value formatting in XML output

  • June 2, 2022
  • 2 replies
  • 44 views

I am using FME 2021.2 with a PostGIS reader and an XML Templater and XML Formatter to write an XML output file. This works fine, but the coordinate X/Y output appears in scientific notation as below:

 <Vertex>

  <X>2.010340655257836E6</X>

  <Y>6.7378739141772166E6</Y>

 </Vertex>

I have tried all kinds of different things, however I can't get FME to format the output they way I want it like below:

    <Vertex>

      <X>2010340.655257836</X>

      <Y>6737873.914177217</Y>

    </Vertex>

This code fragment in the XML Templater works:

<Vertex>

 <X>{geom:get-x-coord()}</X>

 <Y>{geom:get-y-coord()}</Y>

</Vertex>

This does not:

<Vertex>

 {

 let $l := geom:get-x-coord()

 let $r := @Format(%.2f,$l)

 return $r

 }

</Vertex>

I can't figure out how to pass the X value above into the format function, or find another workaround.

Best answer by debbiatsafe

Hi @sdfghjk7777​ 

Please try the following in the XMLTemplater

<Vertex>
    <X>{xs:decimal(geom:get-x-coord())}</X>
    <Y>{xs:decimal(geom:get-y-coord())}</Y>
</Vertex>

This returns decimal notation coordinates in my tests. I hope this information helps.

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

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • Best Answer
  • June 2, 2022

Hi @sdfghjk7777​ 

Please try the following in the XMLTemplater

<Vertex>
    <X>{xs:decimal(geom:get-x-coord())}</X>
    <Y>{xs:decimal(geom:get-y-coord())}</Y>
</Vertex>

This returns decimal notation coordinates in my tests. I hope this information helps.


  • Author
  • 1 reply
  • June 3, 2022

Thank you, that solved my problem. You guys are fantastic. I am just not familiar enough with all the xsd syntactical elements in combination with using the XML Templater.