James Ellis wrote:
a question about namespace attributes in html/xhtml. I'm looking at methods
of conveying information to client side scripts in a neat manner within an
HTML document and trying to be valid at the same time.
My methods works but the validator complains about namespaced attributes.
Method 1: Namespace attributes - works but doesn't validate
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:d="http://example.com/data"
xml:lang="en" lang="en">
<!-- markup -->
<div class="countries">
<div d:country="australia" d:code="au" d:capital="canberra">...</div>
</div>
What's the actual problem or use case you are trying to solve by
introducing namespaced attributes? Your above description is rather
vague. Have you considered that there may be an existing microformats
based method to solve your problem?
Note: "I want to use namespaced attributes" is neither a problem or a
use case, it's a solution; but a solution to what exactly I am unsure.
If you can provide more information about the use case or problem, then
perhaps someone can offer a better alternative.
Method 2: multiple class names
a snippet ...
<div class="countries">
<div class="country:australia code:au capital:canberra">
foo
</div>
</div>
If you are intending to use this in HTML documents, then that kind of
approach would be best.
I'd really like to use Method 1 as it's the cleanest and doesn't involve
unnecessary Javascript. The specs seem to allude to the fact that you
can do this but the validator says no. Does anyone have some ideas about
making it validate?
That's a limitation of DTDs and DTD based validation. They are simply
not expressive enough to describe namespaces properly. The only way you
could work around the validation problem would be to write your own DTD,
but that would be an exercise in futility. Given that you're using
XHTML [1] and because browsers do not use DOCTYPE sniffing for XML
content, you could just omit the DOCTYPE entirely and rely on better
methods conformance checking and validaiton.
[1] I'm assuming by the fact that you think you can use namespaces, you
are actually serving your documents as XML, and not text/html.
Namespaces cannot be used in documents served as text/html. If you do
not understand this MIME type issue, namespaces are most certainly not
the solution to your problem.
--
Lachlan Hunt
http://lachy.id.au/
*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************