How to use attribute as xml path in XMLUPDATER transformer
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.
Page 1 / 1
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?
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.
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.
Thank you @debbiatsafe, your explanation solve my question.