use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class TurtleParser method compose.
public void compose(Element e, Turtle ttl, String base) {
ttl.prefix("fhir", FHIR_URI_BASE);
ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
ttl.prefix("owl", "http://www.w3.org/2002/07/owl#");
ttl.prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
Section section = ttl.section("resource");
String subjId = genSubjectId(e);
String ontologyId = subjId.replace(">", ".ttl>");
Section ontology = ttl.section("ontology header");
ontology.triple(ontologyId, "a", "owl:Ontology");
ontology.triple(ontologyId, "owl:imports", "fhir:fhir.ttl");
if (ontologyId.startsWith("<" + FHIR_URI_BASE))
ontology.triple(ontologyId, "owl:versionIRI", ontologyId.replace(FHIR_URI_BASE, FHIR_VERSION_BASE));
Subject subject = section.triple(subjId, "a", "fhir:" + e.getType());
subject.linkedPredicate("fhir:nodeRole", "fhir:treeRoot", linkResolver == null ? null : linkResolver.resolvePage("rdf.html#tree-root"));
for (Element child : e.getChildren()) {
composeElement(section, subject, child, null);
}
}
use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class TurtleParser method compose.
public void compose(Element e, Turtle ttl, String base) throws FHIRException {
ttl.prefix("fhir", FHIR_URI_BASE);
ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
ttl.prefix("owl", "http://www.w3.org/2002/07/owl#");
ttl.prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
Section section = ttl.section("resource");
String subjId = genSubjectId(e);
String ontologyId = subjId.replace(">", ".ttl>");
Section ontology = ttl.section("ontology header");
ontology.triple(ontologyId, "a", "owl:Ontology");
ontology.triple(ontologyId, "owl:imports", "fhir:fhir.ttl");
if (ontologyId.startsWith("<" + FHIR_URI_BASE))
ontology.triple(ontologyId, "owl:versionIRI", ontologyId.replace(FHIR_URI_BASE, FHIR_VERSION_BASE));
Subject subject = section.triple(subjId, "a", "fhir:" + e.getType());
subject.linkedPredicate("fhir:nodeRole", "fhir:treeRoot", linkResolver == null ? null : linkResolver.resolvePage("rdf.html#tree-root"));
for (Element child : e.getChildren()) {
composeElement(section, subject, child, null);
}
}
use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class RdfParserBase method compose.
@Override
public void compose(OutputStream stream, Resource resource) throws IOException {
Turtle ttl = new Turtle();
// ttl.setFormat(FFormat);
ttl.prefix("fhir", "http://hl7.org/fhir/");
ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
Section section = ttl.section("resource");
Subject subject;
if (url != null)
subject = section.triple("<" + url + ">", "a", "fhir:" + resource.getResourceType().toString());
else
subject = section.triple("[]", "a", "fhir:" + resource.getResourceType().toString());
composeResource(subject, resource);
try {
ttl.commit(stream, false);
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class Turtle method section.
public Section section(String sn) {
if (hasSection(sn))
throw new Error("Duplicate section name " + sn);
Section s = new Section();
s.name = sn;
sections.add(s);
return s;
}
use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.
the class BundleRenderer method addSection.
private void addSection(XhtmlNode x, BaseWrapper section, int level, boolean nested) throws UnsupportedEncodingException, FHIRException, IOException {
if (section.has("title") || section.has("code") || section.has("text") || section.has("section")) {
XhtmlNode div = x.div();
if (section.has("title")) {
div.h(level).tx(section.get("title").primitiveValue());
} else if (section.has("code")) {
renderBase(div.h(level), section.get("code"));
}
if (section.has("text")) {
Base narrative = section.get("text");
x.addChildren(narrative.getXhtml());
}
if (section.has("section")) {
List<BaseWrapper> sections = section.children("section");
for (BaseWrapper child : sections) {
if (nested) {
addSection(x.blockquote().para(), child, level + 1, true);
} else {
addSection(x, child, level + 1, true);
}
}
}
}
// children
}
Aggregations