java-xmlbuilder icon indicating copy to clipboard operation
java-xmlbuilder copied to clipboard

importXMLBuilder removes xmlns:xsi attribute

Open yasarutkuu opened this issue 2 years ago • 2 comments

Hi,

I am trying to import some XMLBuilder2 node into another XMLBuilder2. But while doing this, i faced with this.

When i call below method, it drops xmlns:xsi attribute from elementNode. Have you any idea about this? @jmurty

builder.importXMLBuilder(elementNode);

yasarutkuu avatar Jun 09 '22 12:06 yasarutkuu

@balerilhan

yasarutkuu avatar Jun 09 '22 12:06 yasarutkuu

Hi @yasarutkuu the import method uses the standard Document#importNode method behind the scenes here: https://github.com/jmurty/java-xmlbuilder/blob/0fbd3bc7512f5054711fa6d9ba7160d07ede9cf3/src/main/java/com/jamesmurty/utils/BaseXMLBuilder.java#L314-L316

So what you are seeing is most likely standard (mis)behaviour of the underlying XML import approach, rather than anything specific to XMLBuilder2.

I'd recommend looking to see if you can find a better way of importing element nodes that don't drop xmlns:xsi and do that instead via the underlying objects available from #getDocument or #getElement. Or perhaps hack around it by checking for this attribute before the import and re-adding it again afterwards?

jmurty avatar Jun 14 '22 11:06 jmurty