use of org.hl7.fhir.r5.elementmodel.ParserBase in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.fileToBytes(path);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
use of org.hl7.fhir.r5.elementmodel.ParserBase in project org.hl7.fhir.core by hapifhir.
the class InstanceValidator method validate.
@Override
public org.hl7.fhir.r5.elementmodel.Element validate(Object appContext, List<ValidationMessage> errors, InputStream stream, FhirFormat format, List<StructureDefinition> profiles) throws FHIRException {
ParserBase parser = Manager.makeParser(context, format);
if (parser instanceof XmlParser)
((XmlParser) parser).setAllowXsiLocation(allowXsiLocation);
parser.setupValidation(ValidationPolicy.EVERYTHING, errors);
long t = System.nanoTime();
List<NamedElement> list = null;
try {
list = parser.parse(stream);
} catch (IOException e1) {
throw new FHIRException(e1);
}
timeTracker.load(t);
if (list != null && !list.isEmpty()) {
String url = parser.getImpliedProfile();
if (url != null) {
StructureDefinition sd = context.fetchResource(StructureDefinition.class, url);
if (sd == null) {
rule(errors, IssueType.NOTFOUND, "Payload", false, "Implied profile " + url + " not known to validator");
} else {
profiles.add(sd);
}
}
for (NamedElement ne : list) {
validate(appContext, errors, ne.getName(), ne.getElement(), profiles);
}
}
// todo: this is broken, but fixing it really complicates things elsewhere, so we do this for now
return (list == null || list.isEmpty()) ? null : list.get(0).getElement();
}
use of org.hl7.fhir.r5.elementmodel.ParserBase in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.fileToBytes(path);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
use of org.hl7.fhir.r5.elementmodel.ParserBase in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(InputStream source) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.streamToBytes(source);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
use of org.hl7.fhir.r5.elementmodel.ParserBase in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.fileToBytes(path);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
Aggregations