DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4558>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4558

Undeclared xmlns attributes allowed

           Summary: Undeclared xmlns attributes allowed
           Product: Xerces-J
           Version: 1.4.3
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


It seems that Xerces 1.4.3 has the "xmlns" attribute declared implicitly. The
following document validates, although it shouldn't:

<!DOCTYPE foo [
<!ELEMENT foo (#PCDATA)>
]>
<foo xmlns="http://www.foo.com"/>

Whereas with Crimson and Xerces 2.0, it gives an error like:

Error: URI=file:/home/jeff/tmp/java/jdom/src/java/foo.xml Line=4: Attribute
"xmlns" must be declared for element type "foo".

Here's some code that parses the XML, and silently succeeds with 1.4.3:

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;

public class Broken {
    public static void main(String args[]) throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true); // The default is false. See
http://xml.apache.org/~edwingo/jaxp-faq.html
        dbf.setValidating(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        //db.setErrorHandler(new StandardErrorHandler());
        Document doc = db.parse(new java.io.File(args.length==0?"foo.xml":args[0]));
    }
}


If this is fixed, I hope it's done with big flashing lights, because I'm sure a
lot of people *expect* xmlns attributes to have some sort of magic. I've always
had the vague notion that reserved names starting with [xX][mM][lL] were ignored
by XML parsers. It makes sense to me, because it allows some
backwards-compatibility; you can have an XML file with a default namespace that
will validate in namespace-unaware XML parsers. But it turns out I'm wrong ;P

Thanks,

--Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to