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 1c5bf16bf..6d1d93e92 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 @@ -422,7 +422,11 @@ public class XmlParser extends ParserBase { element.getChildren().add(n); } else { String npath = path+"/"+pathPrefix(child.getNamespaceURI())+child.getLocalName(); - Element n = new Element(child.getLocalName(), property).markLocation(line(child, false), col(child, false)).setFormat(FhirFormat.XML); + String name = child.getLocalName(); + if (!property.isChoice() && !name.equals(property.getName())) { + name = property.getName(); + } + Element n = new Element(name, property).markLocation(line(child, false), col(child, false)).setFormat(FhirFormat.XML); if (property.isList()) { n.setPath(element.getPath()+"."+property.getName()+"["+repeatCount+"]"); } else { diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 1a6aaa327..6ee88c628 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -249,7 +249,7 @@ Validation_VAL_Profile_MultipleMatches_other = Found multiple matching profiles Validation_VAL_Profile_NoDefinition = No definition found for resource type ''{0}'' Validation_VAL_Profile_NoMatch = Unable to find a match for the specified profile among choices: {0} Validation_VAL_Profile_NoSnapshot = StructureDefinition {0} has no snapshot - validation is against the snapshot, so it must be provided -Validation_VAL_Profile_NoType = The type of element {0} is not known, which is invalid. Valid types at this point are {1} +Validation_VAL_Profile_NoType = The type of element {0} is not known - it couild not be determined from the information available. Valid types at this point are {1} Validation_VAL_Profile_NotAllowed = This element is not allowed by the profile {0} Validation_VAL_Profile_NotSlice = This element does not match any known slice {0} and slicing is CLOSED: {1} Validation_VAL_Profile_OutOfOrder = As specified by profile {0}, Element ''{1}'' is out of order (found after {2}) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index d31e8a388..900410dec 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -6215,12 +6215,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if (ed.getRepresentation().isEmpty()) { // ignore xml attributes int count = 0; List slices = null; - if (ed.hasSlicing()) + if (ed.hasSlicing()) { slices = profileUtilities.getSliceList(profile, ed); - for (ElementInfo ei : children) - if (ei.definition == ed) + } + for (ElementInfo ei : children) { + if (ei.definition == ed) { count++; - else if (slices != null) { + } else if (slices != null) { for (ElementDefinition sed : slices) { if (ei.definition == sed) { count++; @@ -6228,6 +6229,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } } } + } if (ed.getMin() > 0) { if (problematicPaths.contains(ed.getPath())) hintPlural(errors, NO_RULE_DATE, IssueType.NOTSUPPORTED, element.line(), element.col(), stack.getLiteralPath(), count >= ed.getMin(), count, I18nConstants.VALIDATION_VAL_PROFILE_NOCHECKMIN, profile.getVersionedUrl(), ed.getPath(), ed.getId(), ed.getSliceName(),ed.getLabel(), stack.getLiteralPath(), Integer.toString(ed.getMin())); @@ -6238,9 +6240,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } } if (ed.hasMax() && !ed.getMax().equals("*")) { - if (problematicPaths.contains(ed.getPath())) + if (problematicPaths.contains(ed.getPath())) { hintPlural(errors, NO_RULE_DATE, IssueType.NOTSUPPORTED, element.line(), element.col(), stack.getLiteralPath(), count <= Integer.parseInt(ed.getMax()), count, I18nConstants.VALIDATION_VAL_PROFILE_NOCHECKMAX, profile.getVersionedUrl(), ed.getPath(), ed.getId(), ed.getSliceName(),ed.getLabel(), stack.getLiteralPath(), ed.getMax()); - else if (count > Integer.parseInt(ed.getMax())) { + } else if (count > Integer.parseInt(ed.getMax())) { ok = rulePlural(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), false, count, I18nConstants.VALIDATION_VAL_PROFILE_MAXIMUM, profile.getVersionedUrl(), ed.getPath(), ed.getId(), ed.getSliceName(),ed.getLabel(), stack.getLiteralPath(), ed.getMax(), Integer.toString(count)) && ok; } }