Introduction
elementFormDefault="unqualified"
on the <schema>
element sets a default form="unqualified"
for the elements defined in that schema.
The following valid XML segment used a schema defined with elementFormDefault="unqualified"
<asnx:module xmlns:asnx="urn:ietf:params:xml:ns:asnx">
<sequence/>
</asnx:module>
The <sequence>
element doesn't have namespace qualification because the schema was defined like this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:ietf:params:xml:ns:asnx"
targetNamespace="urn:ietf:params:xml:ns:asnx"
elementFormDefault="unqualified">
....
Abnormality
In a specific system I'm working with, modularised XHTML was used in the descriptive part of XML data, like this:
<product:description>
<xhtml:div>
<xhtml:p>This product is discontinued</xhtml:p>
</xhtml:div>
</product:description>
Due to the way the software application I'm working on was assembled, it won't work unless it's written in this form:
<product:description>
<xhtml:div>
<p>This product is discontinued</p>
</xhtml:div>
</product:description>
That is, the software application fails to process the embedded XHTML if elements are qualified.
I thought a quick fix is to modify the schema for XHTML namespace to make validator accept embeded XHTML elements unqualified. That is, to change XHTML's schema xhtml1-strict.xsd
(only locally - the system won't reach out to w3.org website to get the official xsd file), by changing the root <schema>
element from elementFormDefault="qualified"
to elementFormDefault="unqualified"
.
To my surprise, the change has no effects. The validator (xmllint) still demand <p>
to be qualified:
element p: Schemas validity error : Element 'p': This element is not expected. Expected is one of ( {http://www.w3.org/1999/xhtml}p, {http://www.w3.org/1999/xhtml}div, {http://www.w3.org/1999/xhtml}fieldset, {http://www.w3.org/1999/xhtml}table, {http://www.w3.org/1999/xhtml}noscript, {http://www.w3.org/1999/xhtml}h1, {http://www.w3.org/1999/xhtml}h2, {http://www.w3.org/1999/xhtml}h3, {http://www.w3.org/1999/xhtml}h4, {http://www.w3.org/1999/xhtml}h5 )
Ruled-out probable causes
I thought maybe I was editing a xhtml1-strict.xsd
not used by the system, so I edited parts of it like changing "div" to "vid" and observe the resulting error. That way I verified that the file I edit is the file used by the validator.
I also tried to change the other schemas imported in the product
namespace and verified that changing elementFormDefault
in any imported schema does have the anticipated effect on the way validator requires the children element to be qualified/unqualified, and that effect is clearly missing when I do the same to xhtml1-strict.xsd
, so there is something magical about xhtml schema.