Skip to main content
Solved

How to use attribute as xml path in XMLUPDATER transformer

  • February 29, 2024
  • 4 replies
  • 189 views

stantf
Contributor
Forum|alt.badge.img+3

I am trying to use attribute, which reprsents search path, to fill in the XML Path in Update section as shown in the screenshot below. But the update is failed. The original value for the element is gone.

 

 

From the translation log, I can see the following warnings. But I cannot figure out why it says about “end of file”. 

 

Please can someone shine a light on the issue?

Thanks.

Best answer by debbiatsafe

Hello @stantf,

The update feature(s) must contain all required attributes in order for the document update to run correctly. In your workspace, the AttributeKeeper_3 feature contains the new values but not the XPath attributes, while the AttributeManager output contains the XPath attributes but not the new values.

Use a FeatureMerger/FeatureJoiner to merge the AttributeKeeper_3 and AttributeManager output before the feeding the merged feature into the XMLUpdater’s Update port.

Note: the reason why hard-coding the attribute values works is due to the first feature to reach the XMLUpdater is AttributeKeeper_3’s feature, which contains the new values but no XPath attribute--no updates are done. The second feature contains the XPath attribute and since the new values are hard-coded, the document update is performed successfully.

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.

4 replies

debbiatsafe
Safer
Forum|alt.badge.img+21

Hello @stantf 

I was able to use an attribute containing an XPath in the XMLUpdater. What version of FME are you using?

Since the error mentioned an unexpected end-of-file syntax error, are you able to check if the XML document in the meta_string attribute is valid using an XMLValidator?

I also see two features being sent into the Update port of the XMLUpdater. What happens if you only connect the AttributeManager output to the Update port?


stantf
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • March 1, 2024

Hi @debbiatsafe,

Thank you for your advice.

The version I am using is 

I added XMLValidator, which conforms that meta_string attribute is vaild.

Instead of supplying the new values for updating the xml elements via the AttributeKeeper, I hardcoded the new values in the XMLUpdater. To my surprise, it worked. The new values can be seen in the outputed xml file. But it raises a new question. Why do the values from AttributeKeeper cause the trouble?

The workbench and xml file are attached for your reference.

 

 


debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • Best Answer
  • March 2, 2024

Hello @stantf,

The update feature(s) must contain all required attributes in order for the document update to run correctly. In your workspace, the AttributeKeeper_3 feature contains the new values but not the XPath attributes, while the AttributeManager output contains the XPath attributes but not the new values.

Use a FeatureMerger/FeatureJoiner to merge the AttributeKeeper_3 and AttributeManager output before the feeding the merged feature into the XMLUpdater’s Update port.

Note: the reason why hard-coding the attribute values works is due to the first feature to reach the XMLUpdater is AttributeKeeper_3’s feature, which contains the new values but no XPath attribute--no updates are done. The second feature contains the XPath attribute and since the new values are hard-coded, the document update is performed successfully.


stantf
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • March 2, 2024

Thank you @debbiatsafe, your explanation solve my question.