Java Code Examples for org.hl7.fhir.utilities.xhtml.XhtmlNode#setAttribute()
The following examples show how to use
org.hl7.fhir.utilities.xhtml.XhtmlNode#setAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceRenderer.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
public static void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); if (r.hasLanguage()) { // use both - see https://www.w3.org/TR/i18n-html-tech-lang/#langvalues x.setAttribute("lang", r.getLanguage()); x.setAttribute("xml:lang", r.getLanguage()); } if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) { r.setText(new Narrative()); r.getText().setDiv(x); r.getText().setStatus(status); } else { XhtmlNode n = r.getText().getDiv(); n.clear(); n.getChildNodes().addAll(x.getChildNodes()); } }
Example 2
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private <T extends Resource> void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) { String ref = null; if (cs != null) { ref = (String) cs.getUserData("filename"); if (Utilities.noString(ref)) ref = (String) cs.getUserData("path"); } if (cs != null && ref != null) { if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/")) ref = ref.substring(20)+"/index.html"; else if (!ref.endsWith(".html")) ref = ref + ".html"; XhtmlNode a = li.addTag("a"); a.setAttribute("href", prefix+ref.replace("\\", "/")); a.addText(inc.getSystem().toString()); } else li.addText(inc.getSystem().toString()); }
Example 3
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 6 votes |
private <T extends Resource> void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) { String ref = null; if (cs != null) { ref = (String) cs.getUserData("filename"); if (Utilities.noString(ref)) ref = (String) cs.getUserData("path"); } if (cs != null && ref != null) { if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/")) ref = ref.substring(20)+"/index.html"; else if (!ref.endsWith(".html")) ref = ref + ".html"; XhtmlNode a = li.addTag("a"); a.setAttribute("href", prefix+ref.replace("\\", "/")); a.addText(inc.getSystem().toString()); } else li.addText(inc.getSystem().toString()); }
Example 4
Source File: BundleRenderer.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void scanInternalLink(Bundle b, XhtmlNode n) { boolean fix = false; for (BundleEntryComponent be : b.getEntry()) { if (be.hasFullUrl() && be.getFullUrl().equals(n.getAttribute("href"))) { fix = true; } } if (fix) { n.setAttribute("href", "#"+makeInternalLink(n.getAttribute("href"))); } }
Example 5
Source File: ElementWrappers.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
@Override public void injectNarrative(XhtmlNode x, NarrativeStatus status) throws IOException { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); String l = wrapped.getChildValue("language"); if (!Utilities.noString(l)) { // use both - see https://www.w3.org/TR/i18n-html-tech-lang/#langvalues x.setAttribute("lang", l); x.setAttribute("xml:lang", l); } org.hl7.fhir.r5.elementmodel.Element txt = wrapped.getNamedChild("text"); if (txt == null) { txt = new org.hl7.fhir.r5.elementmodel.Element("text", wrapped.getProperty().getChild(null, "text")); int i = 0; while (i < wrapped.getChildren().size() && (wrapped.getChildren().get(i).getName().equals("id") || wrapped.getChildren().get(i).getName().equals("meta") || wrapped.getChildren().get(i).getName().equals("implicitRules") || wrapped.getChildren().get(i).getName().equals("language"))) i++; if (i >= wrapped.getChildren().size()) wrapped.getChildren().add(txt); else wrapped.getChildren().add(i, txt); } org.hl7.fhir.r5.elementmodel.Element st = txt.getNamedChild("status"); if (st == null) { st = new org.hl7.fhir.r5.elementmodel.Element("status", txt.getProperty().getChild(null, "status")); txt.getChildren().add(0, st); } st.setValue(status.toCode()); org.hl7.fhir.r5.elementmodel.Element div = txt.getNamedChild("div"); if (div == null) { div = new org.hl7.fhir.r5.elementmodel.Element("div", txt.getProperty().getChild(null, "div")); txt.getChildren().add(div); div.setValue(new XhtmlComposer(XhtmlComposer.XML, context.isPretty()).compose(x)); } div.setValue(x.toString()); div.setXhtml(x); }
Example 6
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) { r.setText(new Narrative()); r.getText().setDiv(x); r.getText().setStatus(status); } else { XhtmlNode n = r.getText().getDiv(); n.hr(); n.getChildNodes().addAll(x.getChildNodes()); } }
Example 7
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void inject(org.hl7.fhir.r4.elementmodel.Element er, XhtmlNode x, NarrativeStatus status) throws IOException, FHIRException { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); org.hl7.fhir.r4.elementmodel.Element txt = er.getNamedChild("text"); if (txt == null) { txt = new org.hl7.fhir.r4.elementmodel.Element("text", er.getProperty().getChild(null, "text")); int i = 0; while (i < er.getChildren().size() && (er.getChildren().get(i).getName().equals("id") || er.getChildren().get(i).getName().equals("meta") || er.getChildren().get(i).getName().equals("implicitRules") || er.getChildren().get(i).getName().equals("language"))) i++; if (i >= er.getChildren().size()) er.getChildren().add(txt); else er.getChildren().add(i, txt); } org.hl7.fhir.r4.elementmodel.Element st = txt.getNamedChild("status"); if (st == null) { st = new org.hl7.fhir.r4.elementmodel.Element("status", txt.getProperty().getChild(null, "status")); txt.getChildren().add(0, st); } st.setValue(status.toCode()); org.hl7.fhir.r4.elementmodel.Element div = txt.getNamedChild("div"); if (div == null) { div = new org.hl7.fhir.r4.elementmodel.Element("div", txt.getProperty().getChild(null, "div")); txt.getChildren().add(div); div.setValue(new XhtmlComposer(XhtmlComposer.XML, pretty).compose(x)); } div.setXhtml(x); }
Example 8
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void renderQuantity(Quantity q, XhtmlNode x, boolean showCodeDetails) { if (q.hasComparator()) x.addText(q.getComparator().toCode()); x.addText(q.getValue().toString()); if (q.hasUnit()) x.addText(" "+q.getUnit()); else if (q.hasCode()) x.addText(" "+q.getCode()); if (showCodeDetails && q.hasCode()) { XhtmlNode sp = x.addTag("span"); sp.setAttribute("style", "background: LightGoldenRodYellow "); sp.addText(" (Details: "+describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')"); } }
Example 9
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void addMapHeaders(XhtmlNode tr, Map<ConceptMap, String> mymaps) { for (ConceptMap m : mymaps.keySet()) { XhtmlNode td = tr.addTag("td"); XhtmlNode b = td.addTag("b"); XhtmlNode a = b.addTag("a"); a.setAttribute("href", prefix+mymaps.get(m)); a.addText(m.hasDescription() ? m.getDescription() : m.getName()); } }
Example 10
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) { r.setText(new Narrative()); r.getText().setDiv(x); r.getText().setStatus(status); } else { XhtmlNode n = r.getText().getDiv(); n.hr(); n.getChildNodes().addAll(x.getChildNodes()); } }
Example 11
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void inject(org.hl7.fhir.dstu3.elementmodel.Element er, XhtmlNode x, NarrativeStatus status) throws DefinitionException, IOException { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); org.hl7.fhir.dstu3.elementmodel.Element txt = er.getNamedChild("text"); if (txt == null) { txt = new org.hl7.fhir.dstu3.elementmodel.Element("text", er.getProperty().getChild(null, "text")); int i = 0; while (i < er.getChildren().size() && (er.getChildren().get(i).getName().equals("id") || er.getChildren().get(i).getName().equals("meta") || er.getChildren().get(i).getName().equals("implicitRules") || er.getChildren().get(i).getName().equals("language"))) i++; if (i >= er.getChildren().size()) er.getChildren().add(txt); else er.getChildren().add(i, txt); } org.hl7.fhir.dstu3.elementmodel.Element st = txt.getNamedChild("status"); if (st == null) { st = new org.hl7.fhir.dstu3.elementmodel.Element("status", txt.getProperty().getChild(null, "status")); txt.getChildren().add(0, st); } st.setValue(status.toCode()); org.hl7.fhir.dstu3.elementmodel.Element div = txt.getNamedChild("div"); if (div == null) { div = new org.hl7.fhir.dstu3.elementmodel.Element("div", txt.getProperty().getChild(null, "div")); txt.getChildren().add(div); div.setValue(new XhtmlComposer(XhtmlComposer.XML).compose(x)); } div.setXhtml(x); }
Example 12
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void renderQuantity(Quantity q, XhtmlNode x, boolean showCodeDetails) { if (q.hasComparator()) x.addText(q.getComparator().toCode()); x.addText(q.getValue().toString()); if (q.hasUnit()) x.addText(" "+q.getUnit()); else if (q.hasCode()) x.addText(" "+q.getCode()); if (showCodeDetails && q.hasCode()) { XhtmlNode sp = x.addTag("span"); sp.setAttribute("style", "background: LightGoldenRodYellow "); sp.addText(" (Details: "+describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')"); } }
Example 13
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void addMapHeaders(XhtmlNode tr, Map<ConceptMap, String> mymaps) { for (ConceptMap m : mymaps.keySet()) { XhtmlNode td = tr.addTag("td"); XhtmlNode b = td.addTag("b"); XhtmlNode a = b.addTag("a"); a.setAttribute("href", prefix+mymaps.get(m)); a.addText(m.hasDescription() ? m.getDescription() : m.getName()); } }
Example 14
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public void generate(Conformance conf) { XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); x.addTag("h2").addText(conf.getName()); smartAddText(x.addTag("p"), conf.getDescription()); ConformanceRestComponent rest = conf.getRest().get(0); XhtmlNode t = x.addTag("table"); addTableRow(t, "Mode", rest.getMode().toString()); addTableRow(t, "Description", rest.getDocumentation()); addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION)); addTableRow(t, "System History", showOp(rest, SystemRestfulInteraction.HISTORYSYSTEM)); addTableRow(t, "System Search", showOp(rest, SystemRestfulInteraction.SEARCHSYSTEM)); t = x.addTag("table"); XhtmlNode tr = t.addTag("tr"); tr.addTag("th").addTag("b").addText("Resource Type"); tr.addTag("th").addTag("b").addText("Profile"); tr.addTag("th").addTag("b").addText("Read"); tr.addTag("th").addTag("b").addText("V-Read"); tr.addTag("th").addTag("b").addText("Search"); tr.addTag("th").addTag("b").addText("Update"); tr.addTag("th").addTag("b").addText("Updates"); tr.addTag("th").addTag("b").addText("Create"); tr.addTag("th").addTag("b").addText("Delete"); tr.addTag("th").addTag("b").addText("History"); for (ConformanceRestResourceComponent r : rest.getResource()) { tr = t.addTag("tr"); tr.addTag("td").addText(r.getType()); if (r.hasProfile()) { XhtmlNode a = tr.addTag("td").addTag("a"); a.addText(r.getProfile().getReference()); a.setAttribute("href", prefix+r.getProfile().getReference()); } tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.READ)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.VREAD)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.UPDATE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.CREATE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.DELETE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE)); } inject(conf, x, NarrativeStatus.GENERATED); }
Example 15
Source File: SpecDifferenceEvaluator.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
private void start() { tbl = new XhtmlNode(NodeType.Element, "table"); tbl.setAttribute("class", "grid"); }
Example 16
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
public void generate(Conformance conf) { XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); x.addTag("h2").addText(conf.getName()); smartAddText(x.addTag("p"), conf.getDescription()); ConformanceRestComponent rest = conf.getRest().get(0); XhtmlNode t = x.addTag("table"); addTableRow(t, "Mode", rest.getMode().toString()); addTableRow(t, "Description", rest.getDocumentation()); addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION)); addTableRow(t, "System History", showOp(rest, SystemRestfulInteraction.HISTORYSYSTEM)); addTableRow(t, "System Search", showOp(rest, SystemRestfulInteraction.SEARCHSYSTEM)); t = x.addTag("table"); XhtmlNode tr = t.addTag("tr"); tr.addTag("th").addTag("b").addText("Resource Type"); tr.addTag("th").addTag("b").addText("Profile"); tr.addTag("th").addTag("b").addText("Read"); tr.addTag("th").addTag("b").addText("V-Read"); tr.addTag("th").addTag("b").addText("Search"); tr.addTag("th").addTag("b").addText("Update"); tr.addTag("th").addTag("b").addText("Updates"); tr.addTag("th").addTag("b").addText("Create"); tr.addTag("th").addTag("b").addText("Delete"); tr.addTag("th").addTag("b").addText("History"); for (ConformanceRestResourceComponent r : rest.getResource()) { tr = t.addTag("tr"); tr.addTag("td").addText(r.getType()); if (r.hasProfile()) { XhtmlNode a = tr.addTag("td").addTag("a"); a.addText(r.getProfile().getReference()); a.setAttribute("href", prefix+r.getProfile().getReference()); } tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.READ)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.VREAD)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.UPDATE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.CREATE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.DELETE)); tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE)); } inject(conf, x, NarrativeStatus.GENERATED); }