Namespace attributes generated without lift:surround tag, causing XHTML Strict 1.0 validation failed
One of my project requirements is to be complaint with XHTML Strict 1.0.
I have set the Lift to use XHTML Strict 1.0 and the Lift generates the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cliff's Test</title>
</head>
<body>
<p>
Hello world!
</p>
<form action="/survey/" method="post">
<p xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml">
<input name="F63599703223BC2" type="submit" value="New" />
<label for="comments">Comments</label><br />
<textarea rows="10" name="F63599693222EH4" cols="40" id="comments">ABC</textarea>
<input name="F63599703223BC2" type="submit" value="New" />
</p>
</form>
<script type="text/javascript" src="/survey/ajax_request/liftAjax.js"></script>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(function() {liftAjax.lift_successRegisterGC();});
var lift_page = "F63599693221SZP";
// ]]>
</script></body>
</html>
It seems to be OK, but when I put them into W3C validator, it points out 1 error:
Line 13, Column 43: Attribute "xmlns" is not a valid attribute. Did you mean "onmouseup" or "onmouseover"?
<p xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml">
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
My original code is:
<!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:lift="http://liftweb.net/">
<head>
<title>Cliff's Test</title>
</head>
<body>
<p>Hello world!</p>
<lift:main.list form="POST">
<p>
<act:new/>
<label for="comments">Comments</label>
<br />
<act:comment/>
<act:new/>
</p>
</lift:main.list>
</body>
</html>
My preliminary analysis is as below:
I have done some investigation and found:
1. The problem does not appear if I use lift:surround
2. It will appear if I do not use lift:surround, namely I do not use any template.
My guess is:
1. using lift:surround, the html tag, which has the xmlns and xmlns:lift attribute, is in the template file; and my main file's root tag is lift:surround and no namespace info. In this case, the xml node sequence passed to bind method does not have any namespace information, therefore the namespaces are not rendered. This is what I expected.
2. when not using template, the html tag with the xmlns and xmlns:lift attribute is the root tag of my main file, and the xml node sequence passed to bind method have the namespace information, therefore, the bind method does not try to detect the rendering context and does nothing to the node sequence and the namespaces get rendered.
I think that the bind method should suppress xmlns attributes.
My test project can be found at http://github.com/zhaotq/playliftweb
I have set the Lift to use XHTML Strict 1.0 and the Lift generates the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cliff's Test</title>
</head>
<body>
<p>
Hello world!
</p>
<form action="/survey/" method="post">
<p xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml">
<input name="F63599703223BC2" type="submit" value="New" />
<label for="comments">Comments</label><br />
<textarea rows="10" name="F63599693222EH4" cols="40" id="comments">ABC</textarea>
<input name="F63599703223BC2" type="submit" value="New" />
</p>
</form>
<script type="text/javascript" src="/survey/ajax_request/liftAjax.js"></script>
<script type="text/javascript">
// <![CDATA[
jQuery(document).ready(function() {liftAjax.lift_successRegisterGC();});
var lift_page = "F63599693221SZP";
// ]]>
</script></body>
</html>
It seems to be OK, but when I put them into W3C validator, it points out 1 error:
Line 13, Column 43: Attribute "xmlns" is not a valid attribute. Did you mean "onmouseup" or "onmouseover"?
<p xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml">
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
My original code is:
<!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:lift="http://liftweb.net/">
<head>
<title>Cliff's Test</title>
</head>
<body>
<p>Hello world!</p>
<lift:main.list form="POST">
<p>
<act:new/>
<label for="comments">Comments</label>
<br />
<act:comment/>
<act:new/>
</p>
</lift:main.list>
</body>
</html>
My preliminary analysis is as below:
I have done some investigation and found:
1. The problem does not appear if I use lift:surround
2. It will appear if I do not use lift:surround, namely I do not use any template.
My guess is:
1. using lift:surround, the html tag, which has the xmlns and xmlns:lift attribute, is in the template file; and my main file's root tag is lift:surround and no namespace info. In this case, the xml node sequence passed to bind method does not have any namespace information, therefore the namespaces are not rendered. This is what I expected.
2. when not using template, the html tag with the xmlns and xmlns:lift attribute is the root tag of my main file, and the xml node sequence passed to bind method have the namespace information, therefore, the bind method does not try to detect the rendering context and does nothing to the node sequence and the namespaces get rendered.
I think that the bind method should suppress xmlns attributes.
My test project can be found at http://github.com/zhaotq/playliftweb
Leave a comment
on 2010-02-28 23:46 *
By dpp
Status changed from Test to Fixed
Work remaining changed from 2.0 to 0.0
(In revision:423585bf2e3f77d7a6586b83e6b56a7cf6a3ff4d) Closes #373. everything that's bound has the TopScope namespace.
Branch: master
Branch: master