XML Schema minOccurs=0 maxOccurs>1 absent element validation behavior
0 reputation · 19 Apr 2024, 21:56 UTC
When defining an optional repeating element in XML Schema with minOccurs="0" and maxOccurs="2" (or unbounded), the specification states the element may appear zero or more times. However, the spec does not explicitly clarify whether an entirely absent element satisfies the maxOccurs constraint when its value exceeds one.
Validation results differ across processors: Xerces-J 2.12.0 treats the missing element as zero occurrences and reports valid, while libxml2 2.12 flags a maxOccurs constraint violation. This divergence creates portability risk for schemas intended to be processor-agnostic.
The goal is to author a schema that validates identically across conforming XML Schema 1.0 processors without relying on implementation-specific behavior.
- Does the XML Schema 1.0 specification mandate a single correct interpretation for this case?
- Is there a schema-level construct (such as a substitution group or conditional type assignment) that forces consistent handling without changing
maxOccurs? - Which processor versions have documented this behavior in their release notes or conformance statements?