use of org.hl7.fhir.dstu2016may.formats.XmlParser in project kindling by HL7.
the class Regenerator method generateOperation.
private void generateOperation(String root, ResourceDefn r, Operation op) throws IOException {
OperationDefinition opd = op.getResource().copy();
opd.setId(r.getName() + "-" + op.getName());
opd.setUrl("http://hl7.org/fhir/build/OperationDefinition/" + opd.getId());
if (!Utilities.noString(op.getFooter())) {
opd.addExtension(BuildExtensions.EXT_FOOTER, new MarkdownType(op.getFooter()));
}
if (!Utilities.noString(op.getFooter2())) {
opd.addExtension(BuildExtensions.EXT_FOOTER2, new MarkdownType(op.getFooter2()));
}
for (OperationExample opex : op.getExamples()) {
Extension ex = new Extension(BuildExtensions.EXT_OP_EXAMPLE);
if (!Utilities.noString(opex.getContent())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(opex.getContent()));
}
if (!Utilities.noString(opex.getComment())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_COMMENT, new StringType(opex.getComment()));
}
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(opex.isResponse()));
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new IntegerType(1));
opd.addExtension(ex);
}
for (OperationExample opex : op.getExamples2()) {
Extension ex = new Extension(BuildExtensions.EXT_OP_EXAMPLE);
if (!Utilities.noString(opex.getContent())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(opex.getContent()));
}
if (!Utilities.noString(opex.getComment())) {
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_COMMENT, new StringType(opex.getComment()));
}
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(opex.isResponse()));
ex.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new IntegerType(2));
opd.addExtension(ex);
}
File fn = new File(Utilities.path(root, opd.fhirType().toLowerCase() + "-" + opd.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), opd);
fn.setLastModified(r.getTimestamp());
}
use of org.hl7.fhir.dstu2016may.formats.XmlParser in project kindling by HL7.
the class Regenerator method generatePacks.
public void generatePacks(ResourceDefn r, String root) throws IOException {
ListResource list = new ListResource();
list.setId(r.getName() + "-packs");
list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.WORKING);
// }
for (Profile p : r.getConformancePackages()) {
ListResourceEntryComponent li = list.addEntry();
li.getItem().setReference("ImplementationGuide/" + r.getName() + "-" + p.getCategory());
}
File fn = new File(Utilities.path(root, list.fhirType().toLowerCase() + "-" + list.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), list);
fn.setLastModified(r.getTimestamp());
// }
for (Profile p : r.getConformancePackages()) {
generateCP(root, r, p);
}
}
use of org.hl7.fhir.dstu2016may.formats.XmlParser in project kindling by HL7.
the class XmlSpecGenerator method renderType.
private String renderType(int indent, DataType value) throws Exception {
StringBuilder b = new StringBuilder();
for (int i = 0; i < indent - 2; i++) b.append(" ");
String ind = b.toString();
XmlParser xml = new XmlParser();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
xml.setOutputStyle(OutputStyle.PRETTY);
xml.compose(bs, null, value);
bs.close();
String[] result = bs.toString().split("\\r?\\n");
b = new StringBuilder();
for (String s : result) {
if (// eliminate the wrapper content
s.startsWith(" "))
b.append("\r\n " + ind + Utilities.escapeXml(s));
}
return b.toString() + "\r\n" + ind;
}
use of org.hl7.fhir.dstu2016may.formats.XmlParser in project kindling by HL7.
the class Publisher method buildLoincExample.
private String buildLoincExample(String filename) throws FileNotFoundException, Exception {
LoincToDEConvertor conv = new LoincToDEConvertor();
conv.setDefinitions(Utilities.path(page.getFolders().srcDir, "loinc", "loincS.xml"));
conv.process();
IParser xml = new XmlParser().setOutputStyle(OutputStyle.PRETTY);
FileOutputStream s = new FileOutputStream(Utilities.path(page.getFolders().dstDir, filename + ".xml"));
xml.compose(s, conv.getBundle());
s.close();
IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
s = new FileOutputStream(Utilities.path(page.getFolders().dstDir, filename + ".json"));
json.compose(s, conv.getBundle());
s.close();
return "Loinc Narrative";
}
use of org.hl7.fhir.dstu2016may.formats.XmlParser in project kindling by HL7.
the class Publisher method produceTypeProfile.
private void produceTypeProfile(TypeDefn type) throws Exception {
// ProfileDefn p = new ProfileDefn();
// p.putMetadata("id", type.getName());
// p.putMetadata("name", "Basic StructureDefinition for " + type.getName());
// p.putMetadata("author.name", "FHIR Specification");
// p.putMetadata("author.ref", "http://hl7.org/fhir");
// p.putMetadata("description", "Basic StructureDefinition for " + type.getName() + " for validation support");
// p.putMetadata("status", "draft");
// p.putMetadata("date", new SimpleDateFormat("yyyy-MM-dd", new Locale("en", "US")).format(new Date()));
// p.getElements().add(type);
// ProfileGenerator pgen = new ProfileGenerator(page.getDefinitions());
// String fn = "type-" + type.getName() + ".profile.xml";
// StructureDefinition rp = pgen.generate(p, "type-" + type.getName() + ".profile", "<div>Type definition for " + type.getName() + " from <a href=\"http://hl7.org/fhir/datatypes.html#" + type.getName()
// + "\">FHIR Specification</a></div>");
String fn = type.getName().toLowerCase() + ".profile.xml";
StructureDefinition rp = type.getProfile();
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + fn);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".canonical.xml"));
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".json"));
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, rp);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(fn, ".canonical.json"));
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, rp);
s.close();
Utilities.copyFile(new CSFile(page.getFolders().dstDir + fn), new CSFile(Utilities.path(page.getFolders().dstDir, "examples", fn)));
addToResourceFeed(rp, page.getTypeBundle(), fn);
// saveAsPureHtml(rp, new FileOutputStream(page.getFolders().dstDir+ "html"
// + File.separator + "datatypes.html"));
cloneToXhtml(type.getName().toLowerCase() + ".profile", "StructureDefinition for " + type.getName(), false, "profile-instance:type:" + type.getName(), "Type", null, wg("mnm"));
jsonToXhtml(type.getName().toLowerCase() + ".profile", "StructureDefinition for " + type.getName(), resource2Json(rp), "profile-instance:type:" + type.getName(), "Type", null, wg("mnm"));
ttlToXhtml(type.getName().toLowerCase() + ".profile", "StructureDefinition for " + type.getName(), resource2Ttl(rp), "profile-instance:type:" + type.getName(), "Type", null, wg("mnm"));
String shex = new ShExGenerator(page.getWorkerContext()).generate(HTMLLinkPolicy.NONE, rp);
TextFile.stringToFile(shex, Utilities.changeFileExt(page.getFolders().dstDir + fn, ".shex"));
shexToXhtml(type.getName().toLowerCase(), "ShEx statement for " + type.getName(), shex, "profile-instance:type:" + type.getName(), "Type", null, wg("mnm"));
}
Aggregations