RE: schema validation and elementFormDefault

"Michael Kay" <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <A5168C55DBED445D81E642CEF650CADC@Sealion>
> 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">
> 
> <RESOURCE/>
> 
> </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
elementFormDefault="qualified".
> 
> 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.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.