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

Martin McEvoy wrote:
> ...
> Agreed but so is this
> 
> <?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 
> xmlns:dc="http://purl.org/dc/elements/1.1/">  <h2 
> property="dc:title">The trouble with Bob</h2>  <h3 
> property="dc:creator">Alice</h3> </div> </body> </html>
> 
> this bit is the problem
> 
> 
> <div xmlns:dc="http://purl.org/dc/elements/1.1/"> ...
> </div>
> 
> the error is Attribute "xmlns:dc" must be declared for element type 
> "div". ie:
>
> <dc:div xmlns:dc="http://purl.org/dc/elements/1.1/"> ...
> </dc:div>

No. This is something entirely different, and not what the validation 
error is about.

> ...
> So there is a problem I think with using xmlns:foo and should be avoided 
> if you intend to serialize your document as XML.
> ...

Only if you intend to validate it using a DTD. DTDs do not support XML 
namespaces.

Move to a technology suited for that purpose, such as RelaxNG, and the 
problem goes away.

BR, Julian

Received on Wednesday, 12 August 2009 15:15:15 UTC