diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParserBase.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParserBase.java index b32a4ee62..70f1fd462 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParserBase.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/formats/XmlParserBase.java @@ -295,9 +295,19 @@ public abstract class XmlParserBase extends ParserBase implements IParser { } - protected void unknownContent(XmlPullParser xpp) throws FHIRFormatError { + protected void unknownContent(XmlPullParser xpp) throws FHIRFormatError, XmlPullParserException, IOException { if (!isAllowUnknownContent()) throw new FHIRFormatError("Unknown Content "+xpp.getName()+" @ "+pathForLocation(xpp)); + // otherwise, read over whatever element this is + int count = 1; + do { + xpp.next(); + if (xpp.getEventType() == XmlPullParser.END_TAG) + count--; + if (xpp.getEventType() == XmlPullParser.START_TAG) + count++; + } while (count > 0); + xpp.next(); } protected XhtmlNode parseXhtml(XmlPullParser xpp) throws XmlPullParserException, IOException, FHIRFormatError { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 73e4c24b3..378489069 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -2494,8 +2494,11 @@ public class ProfileUtilities extends TranslatingUtilities { List list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement(); List profiles = new ArrayList(); profiles.add(profile); - if (list.isEmpty()) - throw new FHIRException((diff ? "Differential" : "Snapshot") + " is empty generating hierarchical table for "+profile.getUrl()); + if (list.isEmpty()) { + ElementDefinition root = new ElementDefinition().setPath(profile.getType()); + root.setId(profile.getType()); + list.add(root); + } genElement(defFile == null ? null : defFile+"#", gen, model.getRows(), list.get(0), list, profiles, diff, profileBaseFileName, null, snapshot, corePath, imagePath, true, logicalModel, profile.getDerivation() == TypeDerivationRule.CONSTRAINT && usesMustSupport(list), allInvariants, null); try { return gen.generate(model, imagePath, 0, outputTracker); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java index 472a9a77f..7a0247507 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/ProfileValidator.java @@ -99,14 +99,18 @@ public class ProfileValidator extends BaseValidator { } } } - for (ElementDefinition diffElement : profile.getDifferential().getElement()) { - ElementDefinition snapElement = snapshotElements.get(diffElement.getId()); - if (snapElement!=null) { // Happens with profiles in the main build - should be able to fix once snapshot generation is fixed - Lloyd - warning(errors, IssueType.BUSINESSRULE, diffElement.getId(), !checkMustSupport || snapElement.hasMustSupport(), "Elements included in the differential should declare mustSupport"); - if (checkAggregation) { - for (TypeRefComponent type : snapElement.getType()) { - if ("http://hl7.org/fhir/Reference".equals(type.getCode()) || "http://hl7.org/fhir/canonical".equals(type.getCode())) { - warning(errors, IssueType.BUSINESSRULE, diffElement.getId(), type.hasAggregation(), "Elements with type Reference or canonical should declare aggregation"); + if (snapshotElements != null) { + for (ElementDefinition diffElement : profile.getDifferential().getElement()) { + if (diffElement == null) + throw new Error("What?"); + ElementDefinition snapElement = snapshotElements.get(diffElement.getId()); + if (snapElement!=null) { // Happens with profiles in the main build - should be able to fix once snapshot generation is fixed - Lloyd + warning(errors, IssueType.BUSINESSRULE, diffElement.getId(), !checkMustSupport || snapElement.hasMustSupport(), "Elements included in the differential should declare mustSupport"); + if (checkAggregation) { + for (TypeRefComponent type : snapElement.getType()) { + if ("http://hl7.org/fhir/Reference".equals(type.getCode()) || "http://hl7.org/fhir/canonical".equals(type.getCode())) { + warning(errors, IssueType.BUSINESSRULE, diffElement.getId(), type.hasAggregation(), "Elements with type Reference or canonical should declare aggregation"); + } } } }