3

My JSF template.xhtml file looks something like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:jsf="http://xmlns.jcp.org/jsf">

<h:head>
    ...
</h:head> 
<h:body>
    <header jsf:id="head">
        ...
    </header>
    <nav jsf:id="nav">
        ...
    </nav>
    <main jsf:id="main">
        ...
    </main>
    <footer jsf:id="foot">
        ...
    </footer>
</h:body>
</html>

Eclipse complains about the

Unknown tag (main).

I wonder whether my file is somehow malformed or Eclipse is just not capable of validating this correctly.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106

1 Answers1

5

This is not a JSF problem. You would still have exactly the same problem when removing the passthrough element trigger jsf:id. You would even still have exactly the same problem when not using JSF tags/attributes anywhere in the XHTML file.

The <main> tag is relatively new in HTML5 (it was only added in HTML5 CR of August 2013). Other HTML5 tags currently in your XHTML document already exist longer (far back in 2008). Eclipse simply doesn't recognize <main> as a tag registered in the default XML namespace as identified by http://www.w3.org/1999/xhtml. Eclipse holds an internal list of registered tags. If upgrading to latest Eclipse (SR) version doesn't solve the problem, then your best bet is to report this as an issue to Eclipse guys. In the meanwhile, just choose the quick fix option "Ignore 'main' element in HTML5 validation".


Unrelated to the concrete problem, that XML prolog doesn't belong there. Get rid of it. Further I also wonder the necessity of the "header", "nav", "main" and "footer" being whole JSF components. I'm not really seeing any useful real world appliances with this. You'd most likely as good just keep them plain HTML. This saves you from unnecessary overhead.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Wow, so they kept the namespace identical for html5? Totally missed that part. That makes the html spec guys even more (imo, the data- prefix instead of a real prefix is imo also a weird choice, as is ditching real good cross validation and more...) – Kukeltje Dec 01 '15 at 09:18
  • Thanks for the great explanation and the further hints. So just to get the last mentioned clear: just `
    ` instead of `
    ` until there is a real need for a JSF component?
    – Jens Piegsa Dec 01 '15 at 09:30
  • 1
    Yep. Start off with bare minimum as long as you can. Only label, input, message and repeater components are mandatory. Others are optional. – BalusC Dec 01 '15 at 09:38