HTML5 Pass-Through element causes Eclipse warning 'Unknown tag'

て烟熏妆下的殇ゞ 提交于 2019-12-10 23:05:33

问题


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.


回答1:


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:

  • XML prolog / instruction not removed from XHTML output
  • JavaServer Faces 2.2 and HTML5 support, why is XHTML still being used


来源:https://stackoverflow.com/questions/34016167/html5-pass-through-element-causes-eclipse-warning-unknown-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!