HTML5 - xhtml strict?

Enonic version: 6.0.0
OS: Win7 Enterprise 64 bit

When using some pages in html I found that I can not use elements like <hr> since then I get:

Caused by: org.xml.sax.SAXParseException: The element type “hr” must be terminated by the matching end-tag “</hr>”.

forcing me to use <hr/> instead, but even the latest html5 draft states clear that this exact element does not require a closing tag:

Similar errors I get working with elements like <meta>, <link>, <script>, making it pretty annoying to clean up the existing code to incorporate into enonic XP views.

Are there any restrictions or any clear rules stating what should or should not be used or something to implicitly tell the parser we dont need to worry about closing tags (like probably use doctype implicitly?)

Alex from Evry

Hi Alex,

The Thymeleaf parser we’re using is sadly forcing this XML syntax on our markup.

To make it work - as you are saying - you must end all tags. Either self-close them or close them separately. Both these lines would work:


In the future we will fix this. They’re working on updating this so you can write 100% pure html5. But I’ll let a developer answer you on the ETA of that.

Best regards,

Thanks Bobby!

You are helpful as always!

Now I see a workaround could be used:

Alex from Evry

1 Like

Imho using valid xml in your markup is a better solution than open-ended elements. I Even bet Google Will like your pages better if they support strict validation…

Coming from an XSLT background, I’ve always used XHTML. But there are times when it’s more convenient to just put an attribute with no =“something”.

I’m not that familiar with Thymeleaf backend. Is there a way to implement legacy without altering the XP code? Where is this templateResolver bean? Or do I just add ‘net.sourceforge.nekohtml:nekohtml:1.9.21’ to the build.gradle file? It would be nice if XP had a setting in a config file that could force legacy mode.

Are there plans to upgrade the Thymeleaf library to use Thymeleaf 3? That would enable the possibility for HTML templating mode, allowing less strict parsing.

We have been running Thymeleaf 3 since summer 2016:

1 Like

Ouch. My newbie apologies - and thanks for the immediate response. Would you know how (or if) I can set the mode to TemplateMode.HTML for my XP project?

Hi there!

This has not been exposed through the library at the moment.
We’re exposing an options parameter for this in the thymeleaf.render(view, model, options) function for 6.10 - hope this will make your day!


Have I told you lately that I love you?


Render mode is fixed in Available in latest snapshot for 6.10.