use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project kindling by HL7.
the class Publisher method processFragment.
private void processFragment(String filename, XhtmlNode node, String type, String clss, String id) throws Exception {
if ("xml".equals(clss)) {
String xml = new XhtmlComposer(XhtmlComposer.XML).compose(node);
Fragment f = new Fragment();
f.setType(type);
f.setXml(Utilities.unescapeXml(xml));
f.setPage(filename);
f.setJson(false);
f.setId(id);
fragments.add(f);
}
if ("json".equals(clss)) {
String xml = new XhtmlComposer(XhtmlComposer.XML).compose(node);
Fragment f = new Fragment();
f.setType(type);
f.setXml(xml);
f.setPage(filename);
f.setId(id);
f.setJson(true);
fragments.add(f);
}
}
use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project kindling by HL7.
the class MappingsGenerator method generate.
public void generate(ResourceDefn resource) throws IOException {
StringBuilder s = new StringBuilder();
List<String> maps = new ArrayList<String>();
listKnownMappings(resource.getRoot(), maps);
Collections.sort(maps, new Sorter());
StringBuilder list = new StringBuilder();
for (String m : maps) {
MappingSpace ms = definitions.getMapTypes().get(m);
list.append("|" + ms.getTitle() + "#" + ms.getId());
s.append("<a name=\"" + m + "\"> </a><a name=\"" + ms.getId() + "\"> </a>");
if (!Utilities.noString(ms.getLink()))
s.append("<h3>" + ms.getTitle() + " (<a href=\"" + ms.getLink() + "\">" + m + "</a>)</h3>");
else
s.append("<h3>" + ms.getTitle() + " (" + m + ")</h3>");
XhtmlNode pre = ms.getPreamble();
if (pre != null)
s.append(new XhtmlComposer(XhtmlComposer.HTML).compose(pre));
s.append("<table class=\"grid\">\r\n");
genElement(s, 0, resource.getRoot(), m, ROOT_ONLY, true, ms.isSparse());
genInherited(s, resource, m);
genElement(s, 0, resource.getRoot(), m, CHILDREN_ONLY, true, ms.isSparse());
s.append("</table>\r\n");
}
mappings = s.toString();
mappingsList = list.length() == 0 ? "" : list.toString().substring(1);
}
use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project kindling by HL7.
the class MappingsGenerator method generate.
public void generate(StructureDefinition profile) throws IOException {
if (profile.getMapping().isEmpty())
mappings = "<p>No Mappings</p>";
else {
StringBuilder s = new StringBuilder();
for (StructureDefinitionMappingComponent map : profile.getMapping()) {
s.append("<a name=\"" + map.getIdentity() + "\"> </a><h3>" + map.getName() + " (" + map.getUri() + ")</h3>");
if (map.hasComment())
s.append("<p>" + Utilities.escapeXml(map.getComment()) + "</p>");
else if (definitions.getMapTypes().containsKey(map.getUri())) {
XhtmlNode pre = definitions.getMapTypes().get(map.getUri()).getPreamble();
if (pre != null)
s.append(new XhtmlComposer(XhtmlComposer.HTML).compose(pre));
}
s.append("<table class=\"grid\">\r\n");
s.append(" <tr><td colspan=\"3\"><b>" + Utilities.escapeXml(profile.getName()) + "</b></td></tr>\r\n");
String path = null;
for (ElementDefinition e : profile.getSnapshot().getElement()) {
if (path == null || !e.getPath().startsWith(path)) {
path = null;
if (e.hasMax() && e.getMax().equals("0")) {
path = e.getPath() + ".";
} else
genElement(s, e, map.getIdentity());
}
}
s.append("</table>\r\n");
}
mappings = s.toString();
}
}
use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project kindling by HL7.
the class MappingsGenerator method generateExtension.
public void generateExtension(StructureDefinition ed) throws IOException {
if (ed.getMapping().isEmpty())
mappings = "<p>No Mappings</p>";
else {
StringBuilder s = new StringBuilder();
for (StructureDefinitionMappingComponent map : ed.getMapping()) {
s.append("<a name=\"" + map.getIdentity() + "\"> </a><h3>" + map.getName() + " (" + map.getUri() + ")</h3>");
if (map.hasComment())
s.append("<p>" + Utilities.escapeXml(map.getComment()) + "</p>");
else if (definitions.getMapTypes().containsKey(map.getUri())) {
XhtmlNode pre = definitions.getMapTypes().get(map.getUri()).getPreamble();
if (pre != null)
s.append(new XhtmlComposer(XhtmlComposer.HTML).compose(pre));
}
s.append("<table class=\"grid\">\r\n");
s.append(" <tr><td colspan=\"3\"><b>" + Utilities.escapeXml(ed.getName()) + "</b></td></tr>\r\n");
String path = null;
for (ElementDefinition e : ed.getSnapshot().getElement()) {
if (path == null || !e.getPath().startsWith(path)) {
path = null;
if (e.hasMax() && e.getMax().equals("0")) {
path = e.getPath() + ".";
} else
genElement(s, e, map.getIdentity());
}
}
s.append("</table>\r\n");
}
mappings = s.toString();
}
}
use of org.hl7.fhir.utilities.xhtml.XhtmlComposer in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method getDiffAsHtml.
public String getDiffAsHtml(TypeLinkProvider linker) throws IOException {
this.linker = linker;
start();
header("Types");
for (String s : sorted(revision.getTypes().keySet())) {
StructureDefinition orig = original.getTypes().get(s);
StructureDefinition rev = revision.getTypes().get(s);
if (orig == null) {
markNew(rev.getName(), true, false, false);
} else if (rev.getKind() == StructureDefinitionKind.PRIMITIVETYPE) {
markNoChanges(rev.getName(), true);
} else if (rev.hasDerivation() && orig.hasDerivation() && rev.getDerivation() != orig.getDerivation()) {
markChanged(rev.getName(), "Changed from a " + orig.getDerivation().toCode() + " to a " + rev.getDerivation().toCode(), true);
} else {
compare(orig, rev);
}
}
for (String s : sorted(original.getTypes().keySet())) {
StructureDefinition orig = original.getTypes().get(s);
StructureDefinition rev = revision.getTypes().get(s);
if (rev == null)
markDeleted(orig.getName(), true);
}
header("Resources");
for (String s : sorted(revision.getResources().keySet())) {
StructureDefinition orig = original.getResources().get(checkRename(s));
StructureDefinition rev = revision.getResources().get(s);
if (orig == null) {
markNew(rev.getName(), true, true, false);
} else {
compare(orig, rev);
}
}
for (String s : sorted(original.getResources().keySet())) {
StructureDefinition orig = original.getResources().get(s);
StructureDefinition rev = revision.getResources().get(s);
if (rev == null)
markDeleted(orig.getName(), true);
}
return new XhtmlComposer(false, true).compose(tbl);
}
Aggregations