In my Facelets template I used a XHTML doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I'd like to change this to HTML5 doctype as per the general recommendation:
<!DOCTYPE html>
However, JSF threw a parsing error:
javax.faces.view.facelets.FaceletException: Error Parsing /template.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared.
The HTML
entity is not parsed then. The entity is used as follows:
<p:menuitem value=" My menuitem">
How is this caused and how can I solve it?
The HTML5 doctype has no predefined entities. It assumes that the entire document is already UTF-8 aware. In other words, you can "safely" put the real non breaking space character in the HTML5 document. However, as it's not trivial to enter it in a visible way using a regular US keyboard, it's understandable that many developers prefer using an entity for it.
Facelets in turn supports as being a XML based view technology only five predefined XML entities <
, >
, &
, "
and '
. The
is not among them.
You've 2 options (apart from the 3rd option to just print the character straight in the document):
Declare the
entity yourself in the doctype:
<!DOCTYPE html [
<!ENTITY nbsp " ">
]>
Or, use the (hexa)decimal notation instead:
  or  
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With