Search code examples
htmljsf-2xhtmluiinclude

jsf 2 ui:include .html give error "XML Parsing Error: no element found"


I include a header.html (not .xhtml) to my page, but when I preview my page, it give me error "XML Parsing Error: no element found". I do know that it is the tag no properly closed issue, but since my header page is a html file, not a xhtml file, it shouldn't must close the tag, am I right?
If I do close all the meta tag in my header.html, my page is working fine, but I wish to know that is it a must close all the tag properly in html file if I include them in jsf2, thanks.

header.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Header</title>
    <meta name="description" content="">
  </head>
  <body>header content</body>
</html>

welcome1.xhtml

<ui:include src="header.html" />
<p>welcome page</p>

Solution

  • From Oracle's documentation, <ui:include> is used to encapsulate and reuse content among multiple XHTML pages. The src attribute is expected to point to a well-formed XML document. Even if you want to include .html pages, you need to make sure all tags are closed properly.