Skip to main content

Hi everyone

 

I have an issue when using a series of XMLAppenders to combine various XML fragments into 1 document which is causing one of my namespaces to be removed and then prefixes to be added to my elements.

 

The first appender works as expected, but then the subsequent one seems to remove one of the tablespace names, and then cause all the existing elements from the document XML to then get the prefix “rsml”. The XML fragment in the 2nd appender doesn’t get the “rmsl” prefix however. I then use a 3rd appender and again this new xml fragment is added fine but still the original and 1st appended XML still have the “rmsl”.

 

My original XML document has the following 3 namespaces:

<railsysml version="0.7" extension="4" xmlns="http://www.rmcon.de/XMLSchema/railsysml/2019/infrastructure_0_7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rsml="http://www.rmcon.de/XMLSchema/railsysml/2019/infrastructure_0_7">

 

1st appender – this is unchanged

2nd and 3rd Appender – this gets changed to <rsml:railsysml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rsml="http://www.rmcon.de/XMLSchema/railsysml/2019/infrastructure_0_7" version="0.7" extension="4"> 

So it appears that the xmlns=http://www.rmcon.de/XMLSchema/railsysml/2019/infrastructure_0_7 is removed by the appender. I assume this is why my elements are then being prefixed with “rmsl”?

I can’t see anywhere in the XMLAppender transformer where I can set anything about Namespaces, so I’m not sure why this is happening? Does anyone have any advice?

 

I have attached an example workbench, input and output data.

 

(I should add I’m no XML expert, so apologies if some of my terminology above isn’t quite right!)

 

The structure of the output I’m after is broadly below but with no rmsl: prefix on any of the elements, and i guess all 3 namespaces I list above?

xmltemplate 

I have also tried just using a StringReplacer at the end of my workflow to remove any “rsml:” strings but with my full data my XML is about 2 million lines long so this transformer was taking too long to run (I left it overnight and it still hadn’t finished). So it would be better for me to fix the issue from happening in the 1st place.

 

Thanks in advance

 

Steph

 

 

Hi @stephstedman​ ,

I don't know why the XMlAppender is removing the namespace but I suspect it's because 2 namespaces are pointing at the same location. Perhaps @deanatsafe​ might be able to help.

A workaround might be to edit the header with the namespaces before the XML Appenders - set it to have just the xmlns:xsi nd xmlns namespaces. Append your data - the tags will not have the rsml prefix. Then after, edit the header to have the 3 namespaces again.

That should mean you are just search/replacing the header.

I've attached an example workspace.

XmlAppend


Hi Mary

Thanks for this, sorry for the late reply, I've been trying lots of different things to get this working!

Your idea above was a great and simple idea to get around my issue, and oddly it did work for a sample subset of my data, but when I ran my whole dataset through it the pre-fixes seemed to be introduced again by some of the XMLAppenders, and I couldn't find a reason why!

 

In the end I solved this problem by changing my method.

 

Use an XMLTemplater to write out the whole XSD to a template, and then I'm using XMLUpdaters to overwrite sections of the template. Then at the end of the workflow I'm just using XMLFormater and some StringReplacers to remove any blank elements and attributes. Anyways, that all seems to work now and don't have weird namespace issues creeping in!

 

Thanks for your help.


Reply