Top level comments in html templates

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Top level comments in html templates

meyertee
Hi,

When running an HTML template such as this one:
  <!DOCTYPE HTML>
  <!--  -->
  <html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head>
      <title></title>
    </head>
    <body>
    </body>
  </html>
I get the following error: org.thymeleaf.exceptions.ParsingException: Invalid document structure: No more than two top-level elements are allowed (either root element, or doctype + root element).

Obviously it's because of the root-comment.. but shouldn't this be legal?
I'd like to use the popular method of adding ie specific classes to the html element as in the html5boilerplate.

I'm happy to file it if you guys approve..
Best, Thomas.
Reply | Threaded
Open this post in threaded view
|

Re: Top level comments in html templates

danielfernandez
Administrator
Hi,

I've just uploaded a new SNAPSHOT version (1.1.0-SNAPSHOT) that should allow you to add comments between the DOCTYPE and the <html> element (which, as you say, is allowed by the standards).

If this works OK, it will go into the upcoming 1.1.0 release.

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: Top level comments in html templates

meyertee
Just checked out the new release, top level comments work now.. that was fast, thank you! Also th:substituteby - just what I needed :)
Cheers, Thomas.
Reply | Threaded
Open this post in threaded view
|

Re: Top level comments in html templates

Emanuel
In reply to this post by danielfernandez
I think this problem is back, albeit with a different exception, in the 2.0.0 release.  Putting a comment between the DOCTYPE and html tags results in an EmptyStackException:

Caused by: java.util.EmptyStackException
        at java.util.Stack.peek(Stack.java:85)
        at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser$XmlSAXHandler.comment(AbstractNonValidatingSAXTemplateParser.java:375)
        at org.apache.xerces.parsers.AbstractSAXParser.comment(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.comment(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanComment(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
        at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.doParse(AbstractNonValidatingSAXTemplateParser.java:154)
        at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.parseTemplateUsingPool(AbstractNonValidatingSAXTemplateParser.java:120)
        at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.parseTemplate(AbstractNonValidatingSAXTemplateParser.java:104)
        at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:269)
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1015)
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:978)
        ... 37 more
Reply | Threaded
Open this post in threaded view
|

Re: Top level comments in html templates

danielfernandez
Administrator
Please check version 2.0.1, released yesterday, which solves this.
Reply | Threaded
Open this post in threaded view
|

Re: Top level comments in html templates

Emanuel
Looks like the problem is fixed in version 2.0.1.  Thanks!