Bootstrap WYSIWIG Editor - invalid XHTML

0
I installed the Bootstrap WYSIWIG Editor in my app. It looks great and fits nicely with Mx5 theming. However, when I put an attribute edited by it in a PDF template and mark the field as Render XHTML, document generation fails. Log info pasted below. Any pointers about how to correct this? 2014-04-18 10:11:42.182 ERROR - Connector: com.mendix.modules.microflowengine.MicroflowException: Error processing XHTML in dynamic label 'textContainer10' that has 'Render XHTML' set to true. Is the XHTML valid? at Proposal.PageTrigger_GeneratePDFProposal (DocumentExport : 'Generate PDF (.pdf) document using template 'ProposalLayout1'') Advanced stacktrace: at com.mendix.modules.microflowengine.MicroflowUtil.processException(SourceFile:158) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: Error processing XHTML in dynamic label 'textContainer10' that has 'Render XHTML' set to true. Is the XHTML valid? at com.mendix.fX.a(SourceFile:122) Caused by: org.xml.sax.SAXParseException: Premature end of file. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(Unknown Source) at com.mendix.fX.a(SourceFile:113) at com.mendix.fX.a(SourceFile:78) at com.mendix.fV.a(SourceFile:327) at com.mendix.ge.a(SourceFile:71) at com.mendix.fV.a(SourceFile:327) at com.mendix.gf.a(SourceFile:76) at com.mendix.fV.a(SourceFile:327) at com.mendix.fU.a(SourceFile:34) at com.mendix.fV.a(SourceFile:327) at com.mendix.ge.a(SourceFile:71) at com.mendix.fV.a(SourceFile:327) at com.mendix.fV.a(SourceFile:131) at com.mendix.fP.a(SourceFile:80) at com.mendix.documentexporter.DocumentGenerator.exportToInputStream(SourceFile:112) at com.mendix.documentexporter.DocumentGenerator.exportToIMendixObject(SourceFile:79) at com.mendix.fL.a(SourceFile:74) at com.mendix.fL.execute(SourceFile:17) at com.mendix.iX.a(SourceFile:47) at com.mendix.iW.a(SourceFile:191) at com.mendix.iW.executeAction(SourceFile:152) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:271) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:206) at com.mendix.core.component.InternalCore.execute(SourceFile:260) at com.mendix.jw.a(SourceFile:135) at com.mendix.pI.a(SourceFile:296) at com.mendix.pI$a.apply$mcI$sp(SourceFile:195) at com.mendix.pI$i.a(SourceFile:211) at com.mendix.pI$i.execute(SourceFile:208) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:132) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) at akka.actor.ActorCell.invoke(ActorCell.scala:456) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) at akka.dispatch.Mailbox.run(Mailbox.scala:219) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
asked
4 answers
3

Unterminated br tags were the cause in my case.

However, replacing them by <br/> did not work as these are removed while generating the PDF content.

I replaced them by p tags, which seems to work just fine.

The rich text / HTML content comes from the widget.

The document generator should work well with HTML content generated within Mendix components. Either the widget or the exporter needs to deal with this, or some common module that 'fixes' the output of the widget so the document generator can work with it, so we only have to call that module.

answered
2

Too big for a comment so a new reply:

I have been experimenting with XSSSanitize in CommunityCommons. As a bonus, the output of the sanitize is XHTML rather than HTML so 'fixing' the content is no longer necessary.

Unfortunately, none of the supplied policy files match the functionality of the widget, especially the option to embed images in the text.

So I made my own.

I registered a ticket about this. I am happy to share my solution and I hope it can be put in CommunityCommons

Please find more info in this topic.

answered
0

Maybe there are unterminated <p> or <br> tags in the HTML. This is allowed by the browsers for 'normal' HTML. XHTML requires all tags to be terminated, for tags without content it must be like <p/> and <br/>.

For our project a similar requirement is scheduled for this week, but I will include a quick test to check whether our content has the same problems.

If I do have the same issue, I will create a ticket with a test project.

Maybe you can create a ticket too, draws more attention to it.

answered
0

I found a userlib --> commons-text-1.10.0 here --> https://commons.apache.org/proper/commons-text/download_text.cgi

Downlaoded the jar file and inserted it in my user lib. Then I created a java action that I use to unescape the HTML -->

// BEGIN USER CODE

return StringEscapeUtils.unescapeHtml4(this.InputHTML_Unescaped);

// END USER CODE

where the static class is imported like this in the upperside of the code -->

import org.apache.commons.text.StringEscapeUtils;

 

answered