[jdom-interest] schema validation and elementFormDefault

Michael Kay mike at saxonica.com
Sun Oct 25 12:35:36 PDT 2009

> When I parse valid document (valid according to a schema using
> elementFormDefault="unqualified") JDOM puts the root element 
> and the child in different namespaces, eg:
> <?xml version="1.0"?>
> <vot:VOTABLE version="1.2" 
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:vot="http://www.ivoa.net/xml/VOTable/v1.2">
> </vot:VOTABLE>
> JDOM puts VOTABLE in the 
> "http://www.ivoa.net/xml/VOTable/v1.2" namepsace and it puts 
> RESOURCE in the "" namespace. 

Quite correct. That's what the schema says it should do.
> SAX (xerces) schema validation says the document is valid, so 
> it must think RESOURCE is in the 
> "http://www.ivoa.net/xml/VOTable/v1.2" namespace; that is the 
> intent of the schema authors.

By using elementFormDefault="unqualified" the schema authors were signifying
that locally-declared elements are in no namespace. If they intended them to
be in the target namespace, they should have used
> Is JDOM wrong in the sense of not being capable of correctly 
> assigning namespaces in this case because it does not check 
> this setting in the schema?

No, JDOM is correct. As I said before, elementFormDefault="unqualified"
gives very counter-intuitive results, and for that reason is rarely used
(except by beginners who don't know better), but if it is used, this is what
it means and JDOM is handling it correctly.


Michael Kay

More information about the jdom-interest mailing list