Bug 4558 - Undeclared xmlns attributes allowed
Summary: Undeclared xmlns attributes allowed
Status: RESOLVED DUPLICATE of bug 1917
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.4.3
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-01 02:52 UTC by Jeff Turner
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Turner 2001-11-01 02:52:45 UTC
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
Comment 1 Henry Zongaro 2001-11-01 06:46:17 UTC
This is the same problem described by bug 1917.  By the way, Xerces2-J doesn't 
have this problem.

*** This bug has been marked as a duplicate of 1917 ***