Skip to main content

Hi,

Im having trouble getting some XML editing working.

Im extracting some elements with XML fragmenter, this generates an XML_ID attribute for each fragment.

Im then filtering for just the fragments I want then wrapping them in another element.

Im then attempting to reinsert the fragments into the XML and I thought I could use the XML_ID attribute to insert each into the position it came from.

Im using //DynamicValue[fme:get-attribute("xml_id")] to try to put them back in

Its basically the structure below but can be more complex

<Item>

<AssOpp>

<DynamicValue><\\DynamicValue>

<DynamicValue><\\DynamicValue>

<DynamicValue><\\DynamicValue>

</AssOpp>

<Item>

I was hoping the XML_ID would place only the filtered edited ones into the correct spot but I seem to be replacing every dynamic value.

The new fragments are like below and the ids look like 'id-DynamicValue1.2.3'

<BuiltInFn><StaticValue><\\StaticValue><DynamicValue><\\DynamicValue><\\BuiltInFn>

Am I attempting this correctly? can the xml_id generated by the fragmenter be used to replace the correct element back in the original document when there are a lot of similar elements?

thanks for any help!

I haven't tried it myself, but have you looked at the XMLUpdater to see if it can help?


I haven't tried it myself, but have you looked at the XMLUpdater to see if it can help?

yeah its the XML updater I'm using, I'm just not sure I'm using this XML_Id thing to get em back in place correctly or if that's why its for, seen one example but cant find it again

 

 


Hi @smurf, I think you will have to specify an XML element to be replaced according to XPath syntax. For example, an XPath indicating the location of "id-DynamicValue-1.2.3" is:

//Item31]/child::*p2]/child::*I3]

If you create this XPath string as an attribute (e.g. named "_xpath") of the feature which will be input to the Update port of the XMLUpdater based on the xml_id, you can then set it to the XML Path column, like this.

0684Q00000ArKrDQAV.png


Hi Takashi,

Thanks for the reply, I ended up solving my issue by adding an ID attribute to the DynamicValues earlier in the process before it gets to the workbench then used that to match up the fragments and re-insert.

Your explanation of the xml_id makes sense, I'll probably have a play around trying to use the xml_Id to get familiar with it.

Thanks for the help.


Reply