When Does xsd:any processContents='lax' Hide Undefined Elements Instead of Reporting Them?
23K reputation · 20 Feb 2024, 14:19 UTC
In XSD 1.0, the xsd:any wildcard supports schema extensibility by allowing elements not declared in the base schema. The processContents attribute controls whether those elements are validated against no schema, a fixed schema, or a lax schema. A common design goal is to permit extension elements while still catching accidental or misspelled elements that belong to a known namespace.
The unresolved decision concerns the interaction between processContents="lax" and the wildcard's namespace attribute. When a lax wildcard encounters an element for which no schema is available, validation ignores it. If the namespace attribute is misconfigured, such as using ##other when a specific target namespace was intended, the validator may silently accept elements that should have been flagged. The same document might validate successfully under lax processing but fail under strict processing.
Verification typically involves comparing validator output for a document containing an undefined element under both modes, using a standard JAXP validator. However, the correct choice for a given extensibility contract remains unclear.
Which conditions cause a lax wildcard to silently ignore an element that has no matching schema declaration? How does the namespace attribute on xsd:any alter that outcome? And when should a schema author prefer strict processing despite the loss of extensibility?