Question

Why can't facelets XHTML files be valid XHTML 1.0 Transitional files? If I submit a facelet file in an xml validator (e.g. w3c validator) it shows an error on the first tag defined in one of the taglibs.

Example 1:

If I submit the following file to the validator, it shows no error, validation goes fine because no taglib tags appear in the document (one jsf taglib is defined though).

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<head>
<title></title>
</head>
<body>
</body>
</html>

Example 2:

Now I just inserted the h:head and h:body tags from the xmlns:h namespace but this causes errors in the validation.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title></title>
</h:head>
<h:body>
</h:body>
</html>

Certainly I'm missing something fundamental here, but I still can't figure out what.

This is my first question here at S.O. so please point out any errors, thank you!

Était-ce utile?

La solution

If you check the Lifecycle of a Facelets Application you can see that your view is rendered to the client. This will transform tags like <h:head> replacing them with their xhtml equivalent e.g. <head>. If you want templates that are XHTML valid you may want to try with the jsfc attribute but it has its drawbacks.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top