fix NPE validating maps

This commit is contained in:
Grahame Grieve 2024-07-30 15:43:56 +08:00
parent 2ebcf267ec
commit 5f2f1972d2
3 changed files with 9 additions and 1 deletions

View File

@ -1103,4 +1103,5 @@ public class I18nConstants {
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF";
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF";
public static final String TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF = "TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF";
public static final String SM_TARGET_TYPE_UNKNOWN = "SM_TARGET_TYPE_UNKNOWN";
}

View File

@ -1131,3 +1131,4 @@ TYPE_SPECIFIC_CHECKS_DT_XHTML_EMPTY_HREF = Hyperlink at ''{0}'' for ''{1}'' is e
TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF = Hyperlink scheme ''{3}'' in ''{0}'' at ''{1}'' for ''{2}'' has active content, which is a security risk and not allowed
TYPE_SPECIFIC_CHECKS_DT_XHTML_UNKNOWN_HREF = Hyperlink scheme ''{3}'' in ''{0}'' at ''{1}'' for ''{2}'' is not a widely supported protocol and should be checked
TYPE_SPECIFIC_CHECKS_DT_XHTML_LITERAL_HREF = Hyperlink scheme ''{3}'' in ''{0}'' at ''{1}'' for ''{2}'' is not a valid hyperlinkable scheme
SM_TARGET_TYPE_UNKNOWN = The type of the target variable is not known: {0}

View File

@ -33,6 +33,7 @@ import org.hl7.fhir.r5.utils.structuremap.ResolvedGroup;
import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities;
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.DebugUtilities;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.i18n.I18nConstants;
@ -742,7 +743,12 @@ public class StructureMapValidator extends BaseValidator {
if (vn != null && type != null) {
StructureDefinition sdt = this.context.fetchTypeDefinition(type);
vn.setType(ruleInfo.getMaxCount(), sdt, sdt.getSnapshot().getElementFirstRep(), null); // may overwrite
if (sdt != null) {
vn.setType(ruleInfo.getMaxCount(), sdt, sdt.getSnapshot().getElementFirstRep(), null); // may overwrite
} else {
ok = false;
rule(errors, "2023-07-30", IssueType.INVALID, target.line(), target.col(), stack.getLiteralPath(), false, I18nConstants.SM_TARGET_TYPE_UNKNOWN, type);
}
}
return ok;
}