This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 800 - xmlns attribute for XML namespace not allowed
Summary: xmlns attribute for XML namespace not allowed
Status: RESOLVED FIXED
Alias: None
Product: Validator
Classification: Unclassified
Component: check (show other bugs)
Version: 0.7.0
Hardware: Other other
: P2 normal
Target Milestone: 0.8.0
Assignee: Olivier Thereaux
QA Contact: qa-dev tracking
URL: http://www.livinglogic.de/Python/
Whiteboard:
Keywords:
Depends on:
Blocks: 4475
  Show dependency treegraph
 
Reported: 2004-06-16 06:39 UTC by Walter D
Modified: 2008-12-01 03:05 UTC (History)
1 user (show)

See Also:


Attachments
Patch to implement ignoring xmlns: attribute declaration errors (1.22 KB, patch)
2007-04-28 03:42 UTC, Shane McCarron
Details
Updated against version 1.507 (1.22 KB, patch)
2007-04-28 04:01 UTC, Shane McCarron
Details
Amended Patch, using XML mode as trigger, matching error number rather than text (667 bytes, patch)
2007-04-30 14:17 UTC, Olivier Thereaux
Details

Description Walter D 2004-06-16 06:39:16 UTC
For the URL http://www.livinglogic.de/Python/ the validator complains about a
namespace declaration for the XML namespace. The XHTML file starts with: 
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:xml="http://www.w3.org/XML/1998/namespace" lang="en" xml:lang="en">

IMHO this namespace declaration should be allowed.
Comment 1 Bj 2004-06-17 18:40:36 UTC
If you check http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd you will 
find that an "xmlns:xml" attribute is not allowed for the <html> element. If 
you think this should be changed, you should read the Status section of the 
XHTML 1.0 Recommendation http://www.w3.org/TR/xhtml1/ and post a comment to the 
www-html-editor mailing list. If you can convince the HTML Working Group to 
change the document type definition we will upgrade the Validator to use the 
new document type definition instead.
Comment 2 Jon Wickstr 2005-12-27 00:25:46 UTC
Comment #1 cleverly avoids stating the original bugreport is invalid. :-)

I get the same error when I have a 'xmlns="http://www.w3.org/1999/xhtml"' 
attribute on an nonroot-element in my document. The DTD only alows (and 
requires) it on the html element.

But isn't the xmlns attribute part of the XML-specification. It is kind of 
part of the layer under XHTML?

The XHTML recommendation states (in http://www.w3.org/TR/xhtml1/#well-formed) 
states that other namespaces MAY be used. But the document is then 
nolonger "strictly conforming". It does not state what the document then is.

But in my case I am not using another namespace. And according to 
http://www.w3.org/TR/REC-xml-names/ the xmlns-attribute is valid on any 
element.
Comment 3 Bj 2005-12-27 18:55:30 UTC
http://www.w3.org/TR/REC-xml-names does not state this, a document is valid or 
namespace-valid iff it meets the constraints of the markup declarations, if you 
do not have a ATTLIST declaration for the xmlns attribute or the xmlns:xml 
attribute on the relevant elements, then the document is not valid; the XHTML 
1.0 DTDs don't do this, so for "XML validity" of "XHTML 1.0 documents" this is 
not allowed. You might disagree with these design decisions of the HTML Working 
Group, in this case you should raise your concern on www-html-editor@w3.org, 
the Validator just checks whether documents meet the constraints, we don't make 
them.
Comment 4 Jeff Jackson 2007-01-05 22:23:02 UTC
The XHTML validator currently complains about the html tag in a document beginning:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">

According to http://www.w3.org/TR/2006/REC-xml-names-20060816 Section 2.1, "An attribute-based declaration syntax is provided to bind prefixes to namespace names and to bind a default namespace that applies to unprefixed element names; these declarations are scoped by the elements on which they appear so that different bindings may apply in different parts of a document. Processors conforming to this specification MUST recognize and act on these declarations and prefixes."

This sounds to me (as claimed before by someone else in Comment #2) like the XML Namespaces rec is saying that xmnls and xmlns-prefixed attributes do not need to be included in any ATTLIST of the DTD in order to be valid; they must be recognized. An attribute-based syntax is used, but these are not standard attributes.

Think of it this way: if a DTD had an ATTLIST containing the single attribute xmlns:hmm, would that mean that I could include a namespace declaration such as xmnls:hmm="http://www.example.org" but I couldn't use a namespace declaration such as xmlns:duh="http://www.example.com"?  Of course not: surely in any document conforming with XML Namespaces I should be able to choose any namespace prefix I want (as long as it isn't reserved).  So xmlns:duh must also be a valid attribute.

This means that xmlns-prefixed attribute specifications cannot be treated the same way for validation purposes as are normal attributes by looking for them in a DTD.  And in light of the quote above, I think that it's clear that xmlns and xmlns-prefixed attributes must be considered valid on every tag in every document conforming with XML Namespaces.

So I believe that it is wrong for the XHTML validator to complain about the html tag above as well as about the original markup in the original bug report and that in Comment #2.  I don't think that this is a problem with the XHTML/XML/XML Namespaces recommendations, but with how the validator is implementing them.
Comment 5 Shane McCarron 2007-04-28 03:42:24 UTC
Created attachment 466 [details]
Patch to implement ignoring xmlns: attribute declaration errors

Actually, since XHTML family document types adhere to the XML and XML Namespace recommendations, Comment #4 is correct - any xmlns:whatever attribute should be permitted on any element.  Unfortunately, this is somewhat challenging to implement in validation engine that we have available.  I have a patch for "check" that permits it to ignore errors of this type against the 0.8.0 beta.  I will attach it here.
Comment 6 Shane McCarron 2007-04-28 04:01:40 UTC
Created attachment 467 [details]
Updated against version 1.507
Comment 7 Olivier Thereaux 2007-04-30 14:17:58 UTC
Created attachment 468 [details]
Amended Patch, using XML mode as trigger, matching error number rather than text

Shane, thanks a lot, your patch looks like a good solution. 
I am attaching a patch with a couple proposed modifications:
* use $File->{Mode} eq 'XML' as trigger rather than an option always set to TRUE, so that usage of xmlns prefix in SGML/HTML mode trigger (correct) errors
* match the internal opensp error message code for the attribute, rather than the text of the error message - which should hopefully be a little more robust (opensp is localized in a few languages, so the error message text could be different)
Comment 8 Olivier Thereaux 2007-05-07 14:28:20 UTC
Patch commited to CVS.