From a80d11334afc423afbcfb0fe8ebcf5f0a3598d97 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 30 Jul 2020 12:01:09 +1000 Subject: [PATCH] Fix bug producing invalid xhtml --- .../r5/renderers/ProfileDrivenRenderer.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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 7f401337a..1ee3f4e45 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 @@ -270,7 +270,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer { return null; } - private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome { + private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode parent, XhtmlNode x, boolean title, boolean showCodeDetails, Map displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome { if (ew == null) return; @@ -361,7 +361,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer { } else { x.an(rw.getId()); ResourceRenderer rr = RendererFactory.factory(rw, context.copy().setAddGeneratedNarrativeHeader(false)); - rr.render(x.blockquote(), rw); + rr.render(parent.blockquote(), rw); } } } else { @@ -598,7 +598,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer { private void generateByProfile(ResourceWrapper res, StructureDefinition profile, BaseWrapper e, List allElements, ElementDefinition defn, List children, XhtmlNode x, String path, boolean showCodeDetails, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome { if (children.isEmpty()) { - renderLeaf(res, e, defn, x, false, showCodeDetails, readDisplayHints(defn), path, indent); + renderLeaf(res, e, defn, x, x, false, showCodeDetails, readDisplayHints(defn), path, indent); } else { for (PropertyWrapper p : splitExtensions(profile, e.children())) { if (p.hasValues()) { @@ -626,7 +626,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer { if (renderAsList(child) && p.getValues().size() > 1) { XhtmlNode list = x.ul(); for (BaseWrapper v : p.getValues()) - renderLeaf(res, v, child, list.li(), false, showCodeDetails, displayHints, path, indent); + renderLeaf(res, v, child, x, list.li(), false, showCodeDetails, displayHints, path, indent); } else { boolean first = true; for (BaseWrapper v : p.getValues()) { @@ -634,7 +634,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer { first = false; else para.tx(", "); - renderLeaf(res, v, child, para, false, showCodeDetails, displayHints, path, indent); + renderLeaf(res, v, child, x, para, false, showCodeDetails, displayHints, path, indent); } } } @@ -730,10 +730,12 @@ public class ProfileDrivenRenderer extends ResourceRenderer { private void addColumnValues(ResourceWrapper res, XhtmlNode tr, List grandChildren, BaseWrapper v, boolean showCodeDetails, Map displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome { for (ElementDefinition e : grandChildren) { PropertyWrapper p = v.getChildByName(e.getPath().substring(e.getPath().lastIndexOf(".")+1)); + XhtmlNode td = tr.td(); if (p == null || p.getValues().size() == 0 || p.getValues().get(0) == null) - tr.td().tx(" "); - else - renderLeaf(res, p.getValues().get(0), e, tr.td(), false, showCodeDetails, displayHints, path, indent); + td.tx(" "); + else { + renderLeaf(res, p.getValues().get(0), e, td, td, false, showCodeDetails, displayHints, path, indent); + } } }