Add support for validating xml:space

This commit is contained in:
Grahame Grieve 2024-08-03 19:31:55 +08:00
parent 7670422a6c
commit b248eb7d67
4 changed files with 14 additions and 2 deletions

View File

@ -4659,7 +4659,7 @@ public class FHIRPathEngine {
}
for (String an : node.getAttributes().keySet()) {
boolean ok = an.startsWith("xmlns") || Utilities.existsInList(an,
"title", "style", "class", "id", "idref", "lang", "xml:lang", "dir", "accesskey", "tabindex",
"title", "style", "class", "id", "idref", "lang", "xml:lang", "xml:space", "dir", "accesskey", "tabindex",
// tables
"span", "width", "align", "valign", "char", "charoff", "abbr", "axis", "headers", "scope", "rowspan", "colspan") ||

View File

@ -1104,4 +1104,5 @@ public class I18nConstants {
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";
public static final String XHTML_XHTML_ATTRIBUTE_XML_SPACE = "XHTML_XHTML_ATTRIBUTE_XML_SPACE";
}

View File

@ -1132,3 +1132,5 @@ TYPE_SPECIFIC_CHECKS_DT_XHTML_ACTIVE_HREF = Hyperlink scheme ''{3}'' in ''{0}''
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}
XHTML_XHTML_ATTRIBUTE_XML_SPACE = The attribute 'xml:space' is legal in XHTML 1.0, and therefore in resources, but was removed in XHTML 1.1, and for this reason it''s use is strongly discouraged

View File

@ -185,6 +185,7 @@ import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPo
import org.hl7.fhir.r5.utils.validation.constants.IdStatus;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.DebugUtilities;
import org.hl7.fhir.utilities.FhirPublication;
import org.hl7.fhir.utilities.HL7WorkGroups;
import org.hl7.fhir.utilities.HL7WorkGroups.HL7WorkGroup;
@ -3299,7 +3300,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
for (String an : node.getAttributes().keySet()) {
boolean bok = an.startsWith("xmlns") || HTML_ATTRIBUTES.contains(an) || HTML_COMBO_LIST.contains(node.getName() + "." + an);
if (!bok) {
ok = rule(errors, NO_RULE_DATE, IssueType.INVALID, e.line(), e.col(), path, false, I18nConstants.XHTML_XHTML_ATTRIBUTE_ILLEGAL, an, node.getName()) && ok;
if ("xml:space".equals(an)) {
warning(errors, "2024-08-03", IssueType.INVALID, e.line(), e.col(), path, false, I18nConstants.XHTML_XHTML_ATTRIBUTE_XML_SPACE, an, node.getName());
} else {
ok = rule(errors, NO_RULE_DATE, IssueType.INVALID, e.line(), e.col(), path, false, I18nConstants.XHTML_XHTML_ATTRIBUTE_ILLEGAL, an, node.getName()) && ok;
}
}
}
@ -3878,6 +3883,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
boolean rok = (allowExamples && (ref.contains("example.org") || ref.contains("acme.com")))
|| (we != null || pol == ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS);
if (!rok) {
DebugUtilities.ln(ref);
DebugUtilities.breakpoint();
}
ok = rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), path, rok, I18nConstants.REFERENCE_REF_CANTRESOLVE, ref) && ok;
}