Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch remaining R5 Turtle RDF generation to TurtleParser implementation #148

Merged
merged 13 commits into from
Dec 17, 2024
Merged
11 changes: 6 additions & 5 deletions src/main/java/org/hl7/fhir/tools/publisher/Publisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2115,8 +2115,7 @@ void serializeResource(Resource r, String baseFileName, String description, Stri
json.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, baseFileName + ".canonical.json")), r);
}
if (showTtl) {
IParser rdf = new RdfParser().setOutputStyle(OutputStyle.PRETTY);
rdf.compose(new FileOutputStream(Utilities.path(page.getFolders().dstDir, baseFileName + ".ttl")), r);
resource2Ttl(r);
}
}
if (description!=null) {
Expand Down Expand Up @@ -4500,9 +4499,11 @@ private String resource2Ttl(Resource r) throws Exception {
// rdf.setSuppressXhtml("Snipped for Brevity");
rdf.compose(bytes, VersionConvertorFactory_40_50.convertResource(r));
} else {
IParser rdf = new RdfParser().setOutputStyle(OutputStyle.PRETTY);
// rdf.setSuppressXhtml("Snipped for Brevity");
rdf.compose(bytes, r);
// R5+ serialization relies on r5.elementmodel.Element, so transform Resource directly into it (instead of getting Element by re-parsing another serialization)
org.hl7.fhir.r5.elementmodel.ResourceParser resourceParser = new org.hl7.fhir.r5.elementmodel.ResourceParser(page.getWorkerContext());
org.hl7.fhir.r5.elementmodel.Element exe = resourceParser.parse(r);
ParserBase tp = Manager.makeParser(page.getWorkerContext(), FhirFormat.TURTLE);
tp.compose(exe, bytes, OutputStyle.PRETTY, null);
}
bytes.close();
return new String(bytes.toByteArray());
Expand Down
Loading