diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index 988323f5c..fc538e297 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -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(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java index ec314cc15..0bcbe02fb 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java @@ -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; } } } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index 1ef878654..b626de371 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -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; + } + } + } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java index 711039f79..00b6cca24 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java @@ -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