Skip to main content
Question

Changes to attributes being used for XML templater

  • December 19, 2022
  • 1 reply
  • 36 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

debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • December 20, 2022

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings