Page 1 of 1

Docx4j 8.3.3 not respecting list when substituting

PostPosted: Fri Jul 08, 2022 1:58 am
by danielshow
Hi
Thanks for all your wonderful work so far on this product, it is been a wonderful ride.

I have two issues:
1. When substituting HTML into word created, it converts the HTML using docx4j-ImportXHTML, the HTML has some lists in it but after generating, everything is seen as a graph.

Sample of the HTML being used
string sub = "<p>Sample <ul><li>Sample List 1</li><li>The services provided include: <ul><li>Cat</li><li>Dog</li></ul></li><ul></p>"
DocxTemplate docx = new DocxTemplate(path);

// we have a function to set value
docx.setValue(key, string)

Logs
Code: Select all
[info] o.d.TraversalUtil - setting to  org.docx4j.vml.CTShapetype
[warn] o.d.TraversalUtil - Parent of org.docx4j.vml.officedrawing.CTLock is currently javax.xml.bind.JAXBElement not org.docx4j.vml.CTShapetype
[info] o.d.TraversalUtil - setting to  org.docx4j.vml.CTShapetype
[warn] o.d.TraversalUtil - Parent of org.docx4j.vml.CTShadow is currently javax.xml.bind.JAXBElement not org.docx4j.vml.CTShape
[info] o.d.TraversalUtil - setting to  org.docx4j.vml.CTShape
[warn] o.d.TraversalUtil - Parent of org.docx4j.vml.CTShadow is currently javax.xml.bind.JAXBElement not org.docx4j.vml.CTShape
[info] o.d.TraversalUtil - setting to  org.docx4j.vml.CTShape
[warn] o.d.c.o.h.HtmlCssHelper - ! null rPr for character style DefaultParagraphFont
[info] o.d.c.i.x.XHTMLImporterImpl -
/* TABLE STYLES */

/* PARAGRAPH STYLES */
.DocDefaults {display:block;margin-bottom: 4mm;line-height: 115%;font-size: 11.0pt;}
.Normal {display:block;}

/* CHARACTER STYLES */ span.DefaultParagraphFont {display:inline;}

org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: SAX XMLReader in use (parser): com.sun.org.apache.xerces.internal.parsers.SAXParser
org.docx4j.org.xhtmlrenderer.load INFO:: Loaded document in ~27ms
org.docx4j.org.xhtmlrenderer.load INFO:: TIME: parse stylesheets  48ms
org.docx4j.org.xhtmlrenderer.match INFO:: media = print
org.docx4j.org.xhtmlrenderer.match INFO:: Matcher created with 136 selectors
[info] o.d.j.NamespacePrefixMapperUtils - Using com.sun.xml.internal NamespacePrefixMapper
[info] o.d.c.i.x.XHTMLImporterImpl - entering list
[info] o.d.c.i.x.XHTMLImporterImpl - entering list
[info] o.d.c.i.x.XHTMLImporterImpl - .. exiting list
[info] o.d.c.i.x.XHTMLImporterImpl - .. exiting list
[info] o.d.c.i.x.XHTMLImporterImpl - entering list
[info] o.d.c.i.x.XHTMLImporterImpl - .. exiting list
[info] o.d.j.NamespacePrefixMapperUtils - Using com.sun.xml.internal NamespacePrefixMapper



Still, it jammed the list together as a paragraph


2. When word art is in a document, it throws an error
Code: Select all
[error] a.a.ActorSystemImpl - Uncaught error from thread [application-akka.actor.default-dispatcher-31]: Bad type on operand stack             
Exception Details:                                                                                                                                                                                                                                                                               
  Location:                                                                                                                                     
    org/docx4j/org/apache/xalan/processor/ProcessorOutputElem.startElement(Lorg/docx4j/org/apache/xalan/processor/StylesheetHandler;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Attributes;)V @142: invokevirtual
  Reason:                                                                                                                                       
    Type 'org/docx4j/org/apache/xalan/templates/OutputProperties' (current frame, stack[1]) is not assignable to 'org/docx4j/org/apache/xalan/templates/ElemTemplateElement'
  Current Frame:           

    same_frame(@119)                                                                                                                           
, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application]
java.lang.VerifyError: Bad type on operand stack                                                                                               
Exception Details:                                                                                                                                                   

Re: Docx4j 8.3.3 not respecting list when substituting

PostPosted: Mon Jul 11, 2022 9:48 am
by jason
Please split this topic into 2 posts, so we maintain one issue per topic.

That said, I'm having trouble making sense of your questions.

Regarding the first, it seems to work ok for me. (Once I changed the last ul tag to a closing tag)

Regarding the second, WordArt of itself should not be a problem. What are you trying to do with the docx - looks like Xalan is being used, but to do what?

Re: Docx4j 8.3.3 not respecting list when substituting

PostPosted: Tue Jul 12, 2022 4:03 am
by danielshow
Thanks for the reply, I will update the posts

For your question on the second issue
I am doing normal Docx generation, In my use case, there is a word addin which is used to generate a template and add some variable templating that we need to replace.

So I got the template which has some WordArt added to it from Microsoft word but when converting and substituting the values. It throws that error. A doc without Microsoft WordArt does not throw an error.