Search in sources :

Example 36 with XhtmlComposer

use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project org.hl7.fhir.core by hapifhir.

the class XmlParserBase method composeXhtml.

protected void composeXhtml(String name, XhtmlNode html) throws IOException {
    if (!Utilities.noString(xhtmlMessage)) {
        xml.enter(XhtmlComposer.XHTML_NS, name);
        xml.comment(xhtmlMessage, false);
        xml.exit(XhtmlComposer.XHTML_NS, name);
    } else {
        XhtmlComposer comp = new XhtmlComposer(XhtmlComposer.XML, htmlPretty);
        // name is also found in the html and should the same
        // ? check that
        boolean oldPretty = xml.isPretty();
        xml.setPretty(htmlPretty);
        if (html.getNodeType() != NodeType.Text && html.getNsDecl() == null)
            xml.namespace(XhtmlComposer.XHTML_NS, null);
        comp.compose(xml, html);
        xml.setPretty(oldPretty);
    }
}
Also used : XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer)

Example 37 with XhtmlComposer

use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project org.hl7.fhir.core by hapifhir.

the class BinaryRenderer method display.

public String display(Binary bin) throws IOException {
    XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
    render(div, bin);
    return new XhtmlComposer(false, true).compose(div);
}
Also used : XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 38 with XhtmlComposer

use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project org.hl7.fhir.core by hapifhir.

the class AdditionalBindingsRenderer method render.

public String render() throws IOException {
    if (bindings.isEmpty()) {
        return "";
    } else {
        XhtmlNode tbl = new XhtmlNode(NodeType.Element, "table");
        tbl.attribute("class", "grid");
        render(tbl.getChildNodes(), true);
        return new XhtmlComposer(false).compose(tbl);
    }
}
Also used : XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 39 with XhtmlComposer

use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project org.hl7.fhir.core by hapifhir.

the class ComparisonRenderer method renderProfile.

private void renderProfile(String id, ProfileComparison comp) throws IOException {
    String template = templates.get("Profile");
    Map<String, Base> vars = new HashMap<>();
    ProfileComparer cs = new ProfileComparer(session, new ProfileUtilities(session.getContextLeft(), null, session.getPkp()), new ProfileUtilities(session.getContextRight(), null, session.getPkp()));
    vars.put("left", new StringType(comp.getLeft().present()));
    vars.put("right", new StringType(comp.getRight().present()));
    vars.put("leftId", new StringType(comp.getLeft().getId()));
    vars.put("rightId", new StringType(comp.getRight().getId()));
    vars.put("leftUrl", new StringType(comp.getLeft().getUrl()));
    vars.put("rightUrl", new StringType(comp.getRight().getUrl()));
    vars.put("errors", new StringType(new XhtmlComposer(true).compose(cs.renderErrors(comp))));
    vars.put("metadata", new StringType(new XhtmlComposer(true).compose(cs.renderMetadata(comp, "", ""))));
    vars.put("structure", new StringType(new XhtmlComposer(true).compose(cs.renderStructure(comp, "", "", "http://hl7.org/fhir"))));
    String cnt = processTemplate(template, "CodeSystem", vars);
    TextFile.stringToFile(cnt, file(comp.getId() + ".html"));
    new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(folder, comp.getId() + "-union.json")), comp.getUnion());
    new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(folder, comp.getId() + "-intersection.json")), comp.getIntersection());
}
Also used : HashMap(java.util.HashMap) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) StringType(org.hl7.fhir.r5.model.StringType) FileOutputStream(java.io.FileOutputStream) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) Base(org.hl7.fhir.r5.model.Base)

Example 40 with XhtmlComposer

use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project org.hl7.fhir.core by hapifhir.

the class ComparisonRenderer method renderValueSet.

private void renderValueSet(String id, ValueSetComparison comp) throws FHIRException, IOException {
    String template = templates.get("ValueSet");
    Map<String, Base> vars = new HashMap<>();
    ValueSetComparer cs = new ValueSetComparer(session);
    vars.put("left", new StringType(comp.getLeft().present()));
    vars.put("right", new StringType(comp.getRight().present()));
    vars.put("leftId", new StringType(comp.getLeft().getId()));
    vars.put("rightId", new StringType(comp.getRight().getId()));
    vars.put("leftUrl", new StringType(comp.getLeft().getUrl()));
    vars.put("rightUrl", new StringType(comp.getRight().getUrl()));
    vars.put("errors", new StringType(new XhtmlComposer(true).compose(cs.renderErrors(comp))));
    vars.put("metadata", new StringType(new XhtmlComposer(true).compose(cs.renderMetadata(comp, "", ""))));
    vars.put("compose", new StringType(new XhtmlComposer(true).compose(cs.renderCompose(comp, "", ""))));
    vars.put("expansion", new StringType(new XhtmlComposer(true).compose(cs.renderExpansion(comp, "", ""))));
    String cnt = processTemplate(template, "ValueSet", vars);
    TextFile.stringToFile(cnt, file(comp.getId() + ".html"));
    new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(folder, comp.getId() + "-union.json")), comp.getUnion());
    new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(folder, comp.getId() + "-intersection.json")), comp.getIntersection());
}
Also used : HashMap(java.util.HashMap) StringType(org.hl7.fhir.r5.model.StringType) FileOutputStream(java.io.FileOutputStream) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) Base(org.hl7.fhir.r5.model.Base)

Aggregations

XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)78 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)31 FHIRException (org.hl7.fhir.exceptions.FHIRException)15 IOException (java.io.IOException)14 FileOutputStream (java.io.FileOutputStream)13 NotImplementedException (org.apache.commons.lang3.NotImplementedException)11 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)11 File (java.io.File)10 FileNotFoundException (java.io.FileNotFoundException)10 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)10 RenderingContext (org.hl7.fhir.r5.renderers.utils.RenderingContext)10 FileInputStream (java.io.FileInputStream)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 HashMap (java.util.HashMap)7 TransformerException (javax.xml.transform.TransformerException)7 XmlParser (org.hl7.fhir.r5.formats.XmlParser)7 ValueSet (org.hl7.fhir.r5.model.ValueSet)7 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)6 URISyntaxException (java.net.URISyntaxException)5 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)5