I'm having a problem with an app I'm developing in xhtml using the xml format for my jsp files. I've been using Firefox during development and have had no problems. However, today I loaded the site in IE and got the following error:
Entity names, PI targets, notation names and attribute values declared to be of
types ID, IDREF(S), ENTITY(IES) or NOTATION cannot contain any colons.
The error refers to the following element:
<input id="_id4:subcontractorId" type="hidden" name="_id4:subcontractorId" value="2" />
From a quick bit of googling, it seems that Microsoft have implemented XML namespaces in the XML parser for IE with no fall-back if the document does not conform to this. The spec for XML namespaces says the following:
The effect of conformance is that in such a document:
* All element types and attribute names contain either zero or one colon.
* No entity names, PI targets, or notation names contain any colons.
Strictly speaking, attribute values declared to be of types ID, IDREF(S), ENTITY(IES), and NOTATION are also Names, and thus should be colon-free.
It seems therefore that jsf is producing invalid xml as far as IE is concerned. Is there any way I can work around this without re-writing all my jsps to produce html?
Example jsp source file:
<?xml version="1.0" ?>
<jsp:root version="2.0"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<f:view>
<f:verbatim><![CDATA[<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]]>
</f:verbatim>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="styles/subcontractor.css" rel="stylesheet" type="text/css"/>
<f:loadBundle basename="uk.co.motives.subcontractors.messages" var="msgs"/>
<title><h:outputText value="#{msgs.startTitle}"/></title>
</head>
<body>
<h2><h:outputText value="#{msgs.startTitle}"/></h2>
<h3><h:outputText value="#{msgs.startPrompt}"/></h3>
<h:form>
<h:commandButton
actionListener="#{subcontractorLoad.load}"
action="#{subcontractorLoad.getLoadOutcome}"
value="#{msgs.startSubcontractorLink}"/>
<h:inputHidden id="subcontractorId" value="2" />
</h:form>
<h:form>
<h:commandButton action="admin" value="#{msgs.startAdminLink}"/>
</h:form>
</body>
</html>
</f:view>
</jsp:root>
Example outputted xhtml document (formatted):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="styles/subcontractor.css"/>
<title>Welcome to the Subcontractors Database</title>
</head>
<body>
<h2>Welcome to the Subcontractors Database</h2>
<h3>Choose a task</h3>
<form id="_id4" method="post" action="/subcontractors/index.faces"
enctype="application/x-www-form-urlencoded">
<input type="submit" name="_id4:_id5" value="A subcontractor" />
<input id="_id4:subcontractorId" type="hidden" name="_id4:subcontractorId" value="2" />
<input type="hidden" name="_id4" value="_id4" />
</form>
<form id="_id6" method="post" action="/subcontractors/index.faces"
enctype="application/x-www-form-urlencoded">
<input type="submit" name="_id6:_id7" value="admin" />
<input type="hidden" name="_id6" value="_id6" />
</form>
</body>
</html>