Skip to main content
Solved

How to use attribute as xml path in XMLUPDATER transformer

  • February 29, 2024
  • 4 replies
  • 140 views

stantf
Contributor
Forum|alt.badge.img+2

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.

View original
Did this help you find an answer to your question?

4 replies

debbiatsafe
Safer
Forum|alt.badge.img+20

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+2
  • 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+20
  • 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+2
  • Author
  • Contributor
  • March 2, 2024

Thank you @debbiatsafe, your explanation solve my question.


Reply


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