diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java index d7d73a167..62c9d5412 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java @@ -442,7 +442,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer { private XhtmlNode renderCommentsSpan(XhtmlNode x, Base e) { if (e.hasFormatComment()) { - return x.span(null, CommaSeparatedStringBuilder.join(" ", e.getFormatCommentsPost())); + return x.span(null, CommaSeparatedStringBuilder.join(" ", e.getFormatCommentsPre())); } else { return x; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DOMWrappers.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DOMWrappers.java index f7800c7e6..ee4b11ada 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DOMWrappers.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/DOMWrappers.java @@ -27,6 +27,7 @@ import org.hl7.fhir.utilities.xhtml.XhtmlParser; import org.hl7.fhir.utilities.xml.XMLUtil; import org.hl7.fhir.utilities.xml.XmlGenerator; import org.w3c.dom.Element; +import org.w3c.dom.Node; public class DOMWrappers { @@ -58,7 +59,15 @@ public class DOMWrappers { } catch (org.hl7.fhir.exceptions.FHIRException e) { throw new FHIRException(e.getMessage(), e); } - return context.getParser().parseType(xml, type); + Node n = element.getPreviousSibling(); + Base ret = context.getParser().parseType(xml, type); + while (n != null && (n.getNodeType() == Node.COMMENT_NODE || n.getNodeType() == Node.TEXT_NODE)) { + if (n.getNodeType() == Node.COMMENT_NODE) { + ret.getFormatCommentsPre().add(0, n.getTextContent()); + } + n = n.getPreviousSibling(); + } + return ret; } @Override