Skip to content

Commit

Permalink
Fix attribute removal preventing next replace
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Herrera <[email protected]>
  • Loading branch information
Pablete1234 committed Dec 11, 2023
1 parent 6ef8f69 commit 18ba63f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions core/src/main/java/tc/oc/pgm/map/MapFilePreprocessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,16 @@ private List<Content> processConditional(Element el, boolean shouldContain)
}

private void postprocessChildren(Element parent) throws InvalidXMLException {
for (Attribute attribute : parent.getAttributes()) {
List<Attribute> attributes = parent.getAttributes();
for (int i = 0; i < attributes.size(); i++) {
Attribute attribute = attributes.get(i);
String result = postprocessString(parent, attribute.getValue());
if (result == null) parent.removeAttribute(attribute);
else attribute.setValue(result);
if (result == null) {
parent.removeAttribute(attribute);
i--;
} else {
attribute.setValue(result);
}
}

for (int i = 0; i < parent.getContentSize(); i++) {
Expand All @@ -177,8 +183,12 @@ private void postprocessChildren(Element parent) throws InvalidXMLException {
Text text = (Text) content;

String result = postprocessString(parent, text.getText());
if (result == null) parent.removeContent(text);
else text.setText(result);
if (result == null) {
parent.removeContent(text);
i--;
} else {
text.setText(result);
}
}
}
}
Expand Down

0 comments on commit 18ba63f

Please sign in to comment.