diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index bd1642270..44a41fdb6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -307,15 +307,16 @@ public class XmlParser extends ParserBase { Node n = node.getFirstChild(); while (n != null) { if (n.getNodeType() == Node.TEXT_NODE && !Utilities.noString(n.getTextContent().trim())) { - while (n.getNextSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) { - n = n.getNextSibling(); + Node nt = n; + while (nt.getNextSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) { + nt = nt.getNextSibling(); } - while (n.getPreviousSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) { - n = n.getPreviousSibling(); + while (nt.getPreviousSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) { + nt = nt.getPreviousSibling(); } - line = line(n); - col = col(n); - logError(line, col, path, IssueType.STRUCTURE, context.formatMessage(I18nConstants.TEXT_SHOULD_NOT_BE_PRESENT, text), IssueSeverity.ERROR); + line = line(nt); + col = col(nt); + logError(line, col, path, IssueType.STRUCTURE, context.formatMessage(I18nConstants.TEXT_SHOULD_NOT_BE_PRESENT, Utilities.makeSingleLine(text)), IssueSeverity.ERROR); } n = n.getNextSibling(); }