Question

Changes to attributes being used for XML templater

  • 19 December 2022
  • 1 reply
  • 4 views

Hi all,

 

I am using FME desktop to publish XMLs out. I'm currently using the XML templater and need to edit one of the attributes that is coming through via a feature reader.

 

The sub template expression looks like this (redacted some lines due to data):

<data>

<dataid>{fme:get-attribute("dataid")}</dataid>

</data>

 

There's several other attributes in the XML but I'm not interested in those.

 

Basically what I would like to do is trim the value in that attribute as the attribute has the current format ABCD*00000000001. I only require the numbers in the attribute and only want these written to the final XML output.

 

How do I go about making changes to the XML attributes. I have tried looking at XQueries but not got very far.

 

Many thanks


1 reply

Userlevel 3
Badge +17

Hello @opannell01​ 

XQuery would be an option if you want to only use XMLTemplater. You should be able to use the XQuery function fn:replace to replace the letters and asterisk symbol in the attribute value with an empty string. For example:

<dataid>{fn:replace({fme:get-attribute("dataid")}, "[A-Za-z]+\*","")}</dataid>

Alternatively, you can also use a StringReplacer transformer with the same regex to get same results for the dataid attribute before the XMLTemplater.

Reply