简体   繁体   中英

How to make facelets conform to XHTML 1.0 Transitional?

Why can't facelets XHTML files be valid XHTML 1.0 Transitional files? If I submit a facelet file in an xml validator (eg 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 SO so please point out any errors, thank you!

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 eg <head> . If you want templates that are XHTML valid you may want to try with the jsfc attribute but it has its drawbacks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM