- This topic has 1 reply, 2 voices, and was last updated 17 years, 3 months ago by Riyad Kalla.
-
AuthorPosts
-
tenjinMemberHi,
I’ve added the XHTML Strict DOCTYPE to otherwise clean JSP files.
<!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”>As expected, there were lots of changes required.
However, it seems to be throwing validation errors that don’t agree wit the XHTML DTD.
For example, it complains about “name” attributes on FORM elements, but that is a valid attribute. It also seems unable to handle conditional tags, for example where multiple “<td class=”xxx”” elements are conditionally inserted into the output file, e.g.:
<tr>
<%
if (session.getAttribute(“eval”) != null)
{
if (contactBean.validateName() == false)
{
%>
<td class=”contactformitemalert”>
<%
}
else
{
%>
<td class=”contactformitem”>
<%
}
}
else
{
%>
<td class=”contactformitem”>
<%
}
%>
Name: <b>*</b></td>
etc. etc.Any ideas how I can improve the XHTML validation?
Cheers
D.
Riyad KallaMemberD.
If you check the xhtml-strict DTD, name is not a valid attribute of the form tag. The form tag is defined as:
<!ATTLIST form %attrs; action %URI; #REQUIRED method (get|post) "get" enctype %ContentType; "application/x-www-form-urlencoded" onsubmit %Script; #IMPLIED onreset %Script; #IMPLIED accept %ContentTypes; #IMPLIED accept-charset %Charsets; #IMPLIED >
and %attrs is defined as the collection of core attributes (id, etc) javascript events and i18n tags… none of which include the “name” attribute.
Also the XHTML validator is strict, it doesn’t understand JSP syntax. So throwing a XHTML doctype in the top of a JSP page doesn’t suddenly make it a XHTML-strict compliant page… this is actually a very complex problem to solve.
I would suggest using xhtml-transitional for the time being as we improve the validators or stick to reporting HTML 4.01 as your doc type for your JSP pages for the time being.
There are quite a few articles online about avoiding XHTML as it’s a spec that is already being talked about getting replaced by the W3C by HTML 5, and how most HTML browsers do not correctly render it… it’s a very fuzzy spec actually.
-
AuthorPosts