use of org.hl7.fhir.definitions.generators.specification.TurtleSpecGenerator in project kindling by HL7.
the class PageProcessor method ttlForDt.
private String ttlForDt(String dt, String pn) throws Exception {
ByteArrayOutputStream b = new ByteArrayOutputStream();
TurtleSpecGenerator gen = new TurtleSpecGenerator(b, pn == null ? null : pn.substring(0, pn.indexOf(".")) + "-definitions.html", null, this, "", version.toCode());
TypeParser tp = new TypeParser(version.toCode());
TypeRef t = tp.parse(dt, false, null, workerContext, true).get(0);
ElementDefn e = definitions.getElementDefn(t.getName());
if (e == null) {
gen.close();
throw new Exception("unable to find definition for " + dt);
} else {
gen.generate(e, false);
gen.close();
}
String val = new String(b.toByteArray()) + "\r\n";
return val;
}
use of org.hl7.fhir.definitions.generators.specification.TurtleSpecGenerator in project kindling by HL7.
the class Publisher method produceResource1.
private void produceResource1(ResourceDefn resource, boolean isAbstract) throws Exception {
String n = resource.getName().toLowerCase();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
XmlSpecGenerator gen = new XmlSpecGenerator(bs, n + "-definitions.html", null, page, "");
gen.generate(resource.getRoot(), isAbstract, true);
gen.close();
String xml = new String(bs.toByteArray());
bs = new ByteArrayOutputStream();
JsonSpecGenerator genJ = new JsonSpecGenerator(bs, n + "-definitions.html", null, page, "", page.getVersion().toCode());
genJ.generate(resource.getRoot(), true, isAbstract);
genJ.close();
String json = new String(bs.toByteArray());
bs = new ByteArrayOutputStream();
TurtleSpecGenerator gent = new TurtleSpecGenerator(bs, n + "-definitions.html", null, page, "", page.getVersion().toCode());
gent.generate(resource.getRoot(), isAbstract);
gent.close();
String ttl = new String(bs.toByteArray());
xmls.put(n, xml);
jsons.put(n, json);
ttls.put(n, ttl);
generateProfile(resource, n, xml, json, ttl, false);
}
use of org.hl7.fhir.definitions.generators.specification.TurtleSpecGenerator in project kindling by HL7.
the class Publisher method produceExtensionDefinition.
private void produceExtensionDefinition(StructureDefinition ed) throws FileNotFoundException, Exception {
if (!ped.contains(ed)) {
ped.add(ed);
ImplementationGuideDefn ig = page.getDefinitions().getIgs().get(ed.getUserString(ToolResourceUtilities.NAME_RES_IG));
String prefix = ig.isCore() ? "" : ig.getCode() + File.separator;
String filename = ed.getUserString("filename");
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + prefix + filename + ".xml");
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, ed);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + prefix + filename + ".canonical.xml");
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, ed);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + prefix + filename + ".json");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, ed);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + prefix + filename + ".canonical.json");
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, ed);
s.close();
cloneToXhtml(prefix + filename, ed.getName(), false, "summary-instance", ed.getUrl(), null, wg(ed));
jsonToXhtml(prefix + filename, ed.getName(), resource2Json(ed), "extension", ed.getUrl(), null, wg(ed));
ttlToXhtml(prefix + filename, ed.getName(), resource2Ttl(ed), "extension", ed.getUrl(), null, wg(ed));
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
XmlSpecGenerator gen = new XmlSpecGenerator(bytes, filename + "-definitions.html", null, /*"http://hl7.org/fhir/"*/
page, page.genlevel(ig.isCore() ? 0 : 1));
gen.generateExtension(ed);
gen.close();
String xml = bytes.toString();
bytes = new ByteArrayOutputStream();
JsonSpecGenerator genj = new JsonSpecGenerator(bytes, filename + "-definitions.html", null, /*"http://hl7.org/fhir/"*/
page, page.genlevel(ig.isCore() ? 0 : 1), page.getVersion().toCode());
genj.generateExtension(ed);
genj.close();
String json = bytes.toString();
bytes = new ByteArrayOutputStream();
TurtleSpecGenerator gent = new TurtleSpecGenerator(bytes, filename + "-definitions.html", null, /*"http://hl7.org/fhir/"*/
page, page.genlevel(ig.isCore() ? 0 : 1), page.getVersion().toCode());
gent.generateExtension(ed);
gent.close();
String ttl = bytes.toString();
bytes = new ByteArrayOutputStream();
TerminologyNotesGenerator tgen = new TerminologyNotesGenerator(bytes, page);
tgen.generateExtension("", ed);
tgen.close();
String tx = bytes.toString();
String src = TextFile.fileToString(page.getFolders().templateDir + "template-extension-mappings.html");
src = page.processExtensionIncludes(filename, ed, xml, json, ttl, tx, src, filename + ".html", ig);
page.getHTMLChecker().registerFile(prefix + filename + "-mappings.html", "Mappings for Extension " + ed.getName(), HTMLLinkChecker.XHTML_TYPE, true);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + filename + "-mappings.html");
src = TextFile.fileToString(page.getFolders().templateDir + "template-extension-definitions.html");
src = page.processExtensionIncludes(filename, ed, xml, json, ttl, tx, src, filename + ".html", ig);
page.getHTMLChecker().registerFile(prefix + filename + "-definitions.html", "Definitions for Extension " + ed.getName(), HTMLLinkChecker.XHTML_TYPE, true);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + filename + "-definitions.html");
src = TextFile.fileToString(page.getFolders().templateDir + "template-extension.html");
src = page.processExtensionIncludes(filename, ed, xml, json, ttl, tx, src, filename + ".html", ig);
page.getHTMLChecker().registerFile(prefix + filename + ".html", "Extension " + ed.getName(), HTMLLinkChecker.XHTML_TYPE, true);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + filename + ".html");
}
}
Aggregations