better handling for sax errors and jvm issue
This commit is contained in:
parent
93ec88ee24
commit
86a3a56c42
|
@ -155,7 +155,13 @@ public class XmlParser extends ParserBase {
|
|||
doc = builder.parse(stream);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError(0, 0, "(syntax)", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
|
||||
if (e.getMessage().contains("lineNumber:") && e.getMessage().contains("columnNumber:")) {
|
||||
int line = Utilities.parseInt(extractVal(e.getMessage(), "lineNumber"), 0);
|
||||
int col = Utilities.parseInt(extractVal(e.getMessage(), "columnNumber"), 0);
|
||||
logError(line, col, "(xml)", IssueType.INVALID, e.getMessage().substring(e.getMessage().lastIndexOf(";")+1).trim(), IssueSeverity.FATAL);
|
||||
} else {
|
||||
logError(0, 0, "(syntax)", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
|
||||
}
|
||||
doc = null;
|
||||
}
|
||||
if (doc != null) {
|
||||
|
@ -168,6 +174,11 @@ public class XmlParser extends ParserBase {
|
|||
}
|
||||
|
||||
|
||||
private String extractVal(String src, String name) {
|
||||
src = src.substring(src.indexOf(name)+name.length()+1);
|
||||
src = src.substring(0, src.indexOf(";")).trim();
|
||||
return src;
|
||||
}
|
||||
private void checkForProcessingInstruction(Document document) throws FHIRFormatError {
|
||||
if (policy == ValidationPolicy.EVERYTHING && FormatUtilities.FHIR_NS.equals(document.getDocumentElement().getNamespaceURI())) {
|
||||
Node node = document.getFirstChild();
|
||||
|
|
|
@ -583,7 +583,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
|||
return false;
|
||||
}
|
||||
CodeSystem cs = resolveCodeSystem(vsi.getSystem());
|
||||
if (cs != null) {
|
||||
if (cs != null && cs.getContent() == CodeSystemContentMode.COMPLETE) {
|
||||
|
||||
if (vsi.hasConcept()) {
|
||||
for (ConceptReferenceComponent cc : vsi.getConcept()) {
|
||||
|
@ -598,15 +598,15 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
|||
sys.add(vsi.getSystem());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (vsi.hasConcept()) {
|
||||
for (ConceptReferenceComponent cc : vsi.getConcept()) {
|
||||
boolean match = cc.getCode().equals(code);
|
||||
if (match) {
|
||||
sys.add(vsi.getSystem());
|
||||
}
|
||||
} else if (vsi.hasConcept()) {
|
||||
for (ConceptReferenceComponent cc : vsi.getConcept()) {
|
||||
boolean match = cc.getCode().equals(code);
|
||||
if (match) {
|
||||
sys.add(vsi.getSystem());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1758,4 +1758,12 @@ public class Utilities {
|
|||
return text;
|
||||
}
|
||||
|
||||
public static int parseInt(String value, int def) {
|
||||
if (isInteger(value)) {
|
||||
return Integer.parseInt(value);
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -140,7 +140,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
long setup = System.nanoTime();
|
||||
|
||||
this.name = name;
|
||||
System.out.println("---- " + name + " ----------------------------------------------------------------");
|
||||
System.out.println("---- " + name + " ---------------------------------------------------------------- ("+System.getProperty("java.vm.name")+")");
|
||||
System.out.println("** Core: ");
|
||||
String txLog = null;
|
||||
if (content.has("txLog")) {
|
||||
|
@ -529,13 +529,27 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
private OperationOutcomeIssueComponent findMatchingIssue(OperationOutcome oo, OperationOutcomeIssueComponent iss) {
|
||||
for (OperationOutcomeIssueComponent t : oo.getIssue()) {
|
||||
if (t.getExpression().get(0).getValue().equals(iss.getExpression().get(0).getValue()) && t.getCode() == iss.getCode() && t.getSeverity() == iss.getSeverity()
|
||||
&& (t.hasDiagnostics() ? t.getDiagnostics().equals(iss.getDiagnostics()) : !iss.hasDiagnostics()) && t.getDetails().getText().trim().equals(iss.getDetails().getText().trim())) {
|
||||
&& (t.hasDiagnostics() ? t.getDiagnostics().equals(iss.getDiagnostics()) : !iss.hasDiagnostics()) && textMatches(t.getDetails().getText(), iss.getDetails().getText())) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean textMatches(String t1, String t2) {
|
||||
if (t1.endsWith("...")) {
|
||||
t2 = t2.substring(0, t1.length()-3);
|
||||
t1 = t1.substring(0, t1.length()-3);
|
||||
}
|
||||
if (t2.endsWith("...")) {
|
||||
t1 = t1.substring(0, t2.length()-3);
|
||||
t2 = t2.substring(0, t2.length()-3);
|
||||
}
|
||||
t1 = t1.trim();
|
||||
t2 = t2.trim();
|
||||
return t1.equals(t2);
|
||||
}
|
||||
|
||||
private org.hl7.fhir.r4.model.Parameters makeExpProfile() {
|
||||
org.hl7.fhir.r4.model.Parameters ep = new org.hl7.fhir.r4.model.Parameters();
|
||||
ep.addParameter("profile-url", "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"); // change this to blow the cache
|
||||
|
|
Loading…
Reference in New Issue