fix comment rendering

This commit is contained in:
Grahame Grieve 2022-08-26 23:00:24 +10:00
parent 5220f2552b
commit 22d48d15cf
2 changed files with 11 additions and 2 deletions

View File

@ -442,7 +442,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
private XhtmlNode renderCommentsSpan(XhtmlNode x, Base e) { private XhtmlNode renderCommentsSpan(XhtmlNode x, Base e) {
if (e.hasFormatComment()) { if (e.hasFormatComment()) {
return x.span(null, CommaSeparatedStringBuilder.join("
", e.getFormatCommentsPost())); return x.span(null, CommaSeparatedStringBuilder.join("
", e.getFormatCommentsPre()));
} else { } else {
return x; return x;
} }

View File

@ -27,6 +27,7 @@ import org.hl7.fhir.utilities.xhtml.XhtmlParser;
import org.hl7.fhir.utilities.xml.XMLUtil; import org.hl7.fhir.utilities.xml.XMLUtil;
import org.hl7.fhir.utilities.xml.XmlGenerator; import org.hl7.fhir.utilities.xml.XmlGenerator;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class DOMWrappers { public class DOMWrappers {
@ -58,7 +59,15 @@ public class DOMWrappers {
} catch (org.hl7.fhir.exceptions.FHIRException e) { } catch (org.hl7.fhir.exceptions.FHIRException e) {
throw new FHIRException(e.getMessage(), 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 @Override