jsfxml-entities

XML entities don't render


Using h:outputText I want to display a left arrow ← using ←. But it just doesn't render on the page (not even in the inspect element output). What did I do wrong?

<h:outputText value="Overtime (Remaining &larr; New)" />

enter image description here


Solution

  • Root problem is, &larr; is not a XML entity. It's a HTML entity.

    Facelets is XML based and XML has only 5 predefined entities: &amp;, &quot;, &apos;, &lt;, &gt;. All others you might have seen or heard about are all HTML entities and not supported in XML.

    Historically, HTML entities were used to support "special" characters anyway when using inferior character encodings such as ISO-XXX instead of UTF-XXX. But since the introduction and worldwide support of UTF-XXX character encodings, we don't really need these HTML entities anymore.

    XML supports UTF-8, so just print right away.

    <h:outputText value="Overtime (Remaining ← New)" />
    

    Or even without a whole <h:outputText> as you don't actually need to convert anything here.

    Overtime (Remaining ← New)
    

    See also: