From 6bd21042c7adcde067d1786ccedcb0cd91de6002 Mon Sep 17 00:00:00 2001 From: Paul Libbrecht Date: Tue, 2 Mar 2021 14:56:40 +0100 Subject: [PATCH] Comment to explain why we use this method of replacmeent. --- .../src/main/java/org/xwiki/tool/xar/XARMojo.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/XARMojo.java b/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/XARMojo.java index c864555ab4..bdf547f3ac 100644 --- a/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/XARMojo.java +++ b/xwiki-commons-tools/xwiki-commons-tool-xar/xwiki-commons-tool-xar-plugin/src/main/java/org/xwiki/tool/xar/XARMojo.java @@ -221,6 +221,10 @@ private void performTransformations() throws Exception if (parent == null) { document = xmlDocument; } else { + // this is the method we use to replace the child and it seems to be + // the canonical way in dom4j (for which a manipulation on a collection + // is a manipulation of the XML tree: We manipulate the elements' list + // by setting the child at the position where it was found. List siblings = parent.elements(); siblings.set(siblings.indexOf(node), xmlElement); }