Re: The "real" reason why xmlns should "not" be used

On Wed, 2009-08-12 at 14:10 +0100, Martin McEvoy wrote:
> If I remove all the namespace declarations from the example I gave you 
> there is no problems parsing the document as XML
> 
> http://www.validome.org/xml/validate/?lang=en&viewSourceCode=1&url=http://weborganics.co.uk/test/xhtml-test2.xhtml

Yes that document is valid whereas your first one was not, but my point
is that the namespace declarations are not the real reason your first
document was invalid. The following document, which contains no Dublin
Core namespace declaration is equally invalid:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
 <title>xhtml test</title> 
</head> 
<body> 
<h1>XHTML test</h1> 
<div foo-dc="http://purl.org/dc/elements/1.1/"> 
  <h2 property="dc:title">The trouble with Bob</h2> 
  <h3 property="dc:creator">Alice</h3> 
</div> 
<bar-div foo-dc="http://purl.org/dc/elements/1.1/"> 
  <h2 property="dc:title">The trouble with Bob</h2> 
  <h3 property="dc:creator">Alice</h3> 
</bar-div>  
</body> 
</html>

You see? While the DC namespace declarations in your original example
may have triggered the errors you originally saw; the same errors can be
triggered without namespace declarations. The errors in your example
were entirely caused by the fact that <dc:div> and xmlns:dc are
undefined in the RDFa DTD. 

The former is not a problem as RDFa doesn't use dc:div. 

The latter is a theoretical problem (see my message entitled "Possible
RDFa errata") but rather than being a major issue with RDFa, it
highlights the limitation of DTDs as a technology for validating
documents that make use of some of the more interesting features XML has
to offer, like namespaces - this is presumably one of the reasons that
the HTML5 effort has abandoned using DTDs for validation.

But none of this has anything to do with your original assertion, which
was that the following are equivalent in meaning:

 <div xmlns:dc="http://purl.org/dc/elements/1.1/">

and:

 <dc:div xmlns:dc="http://purl.org/dc/elements/1.1/">

In fact, the former example is equivalent to:

 <xh:div xmlns:xh="http://www.w3.org/1999/xhtml"
  xmlns:dc="http://purl.org/dc/elements/1.1/">

As can be understood by a thorough reading of the XML namespace
document.

RDFa does not do anything special that pulls XHTML elements out of the
XHTML namespace and puts them into Dublin Core or any other XML
namespace. All the elements and attributes defined or used by XHTML+RDFa
1.0 are in the http://www.w3.org/1999/xhtml namespace (with the
exception of xml:lang and the xmlns:* attributes themselves).

-- 
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>

Received on Wednesday, 12 August 2009 14:30:05 UTC