sitimoen / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Problem processing the docx as Velocity Template #275

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1.Take the attached docx file
2.Try to parse it
3. Will throw exception

What is the expected output? What do you see instead?
org.apache.velocity.exception.ParseErrorException: Lexical error,   
Encountered: "\u00bb" (187), after : "" at 
fr.opensagres.xdocreport.document.docx.DocxReport@5c57a5e9!word/document.xml[lin
e 1, column 25219]
    at org.apache.velocity.Template.process(Template.java:151)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:437)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
    at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
    at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:392)
    at fr.opensagres.xdocreport.template.velocity.internal.VelocityTemplateEngine.processWithCache(VelocityTemplateEngine.java:96)
    at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:111)
    at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:83)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.processTemplateEngine(AbstractXDocReport.java:772)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:518)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:484)
    at com.dset.greenleaf.report.GLReportDocx.generate(GLReportDocx.java:102)

What version of the product are you using? On what operating system?
1.0.2 on Linux

Please provide any additional information below.

Word generated with Microsoft Word 2010 Version: 14.0.6023.1000 (32bits)

Original issue reported on code.google.com by dseg...@dset-solutions.com on 12 Jun 2013 at 9:43

Attachments:

GoogleCodeExporter commented 8 years ago
I have seen your docx and it is very complex. So it's very hard to debug your 
problem. More I have not your Java context. So it's impossible for me to help 
you.

I cannot take time to find your problem. The only solution is to try to 
generate your report step by step by removing some contents and see what is 
your problem.

If you find your problem with a simple docx, I could help you.
Good lucks!

Regards Angelo

Original comment by angelo.z...@gmail.com on 12 Jun 2013 at 9:52

GoogleCodeExporter commented 8 years ago
Ok thank you for your fast replay, I'm going to try to generate my report
step by step.

Regards

Dolors

-- 

*Dolors Segura*
*�rea de software
*697.429.220 / 972.104.177 (Ext. 2)  - dsegura@dset-solutions.com

*DSET Solutions *
*Parc Cient�fic i Tecnol�gic de la UdG - 17003 Girona*
http://www.dset-solutions.com
<http://www.dset-solutions.com/es/avis-legal.html>

Av�s 
legal<http://www.dset-solutions.com/index.php?option=com_content&id=159&view=art
icle&lang=ca>

Original comment by dseg...@dset-solutions.com on 12 Jun 2013 at 10:03

GoogleCodeExporter commented 8 years ago
Angelo I found the same error in this simple docx.

org.apache.velocity.exception.ParseErrorException: Lexical error,   
Encountered: "\u00bb" (187), after : "" at 
fr.opensagres.xdocreport.document.docx.DocxReport@1e64621f!word/document.xml[lin
e 1, column 12154]
    at org.apache.velocity.Template.process(Template.java:151)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:437)
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
    at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
    at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:392)
    at fr.opensagres.xdocreport.template.velocity.internal.VelocityTemplateEngine.processWithCache(VelocityTemplateEngine.java:96)
    at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:111)
    at fr.opensagres.xdocreport.template.AbstractTemplateEngine.process(AbstractTemplateEngine.java:83)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.processTemplateEngine(AbstractXDocReport.java:772)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:518)
    at fr.opensagres.xdocreport.document.AbstractXDocReport.process(AbstractXDocReport.java:484)
    at com.dset.greenleaf.report.GLReportDocx.generate(GLReportDocx.java:102)

Java Code:

IXDocReport report = XDocReportRegistry.getRegistry().loadReport(reportSource, 
TemplateEngineKind.Velocity);

                FieldsMetadata metadata = new FieldsMetadata();
                addListParameters(metadata);
                report.setFieldsMetadata(metadata);

                IContext context = report.createContext();
                Map parameters = getParameters();
                Set<String> keySet = parameters.keySet();
                Iterator<String> it = keySet.iterator();
                while (it.hasNext()) {
                    String key = it.next();
                    context.put(key, parameters.get(key));
                }

// Data --> empty List
                context.put("rows", data);

                report.process(context, out);

Thanks,

Dolors

Original comment by dseg...@dset-solutions.com on 12 Jun 2013 at 11:34

GoogleCodeExporter commented 8 years ago
OK, could you attach please your docx and your Java code (main + context which 
works) in order to I can debug it. Without that I cannot help you.

Original comment by angelo.z...@gmail.com on 12 Jun 2013 at 1:34

GoogleCodeExporter commented 8 years ago
Sorry, this is a zip with the example code and my docx.

Thanks,

Dolors

Original comment by dseg...@dset-solutions.com on 12 Jun 2013 at 2:09

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Dolors,

It was a bug with XDocReport. I have fixed the problem (see Git commit 
https://code.google.com/p/xdocreport/source/detail?r=9f0eea707d26c6114443d99d86f
071c1fdacd051)

The problem was that you have an hyperlink and XDocReport didn't reinitialize 
it and you had your problem. The problem is fixed for 1.0.3.

Original comment by angelo.z...@gmail.com on 17 Jun 2013 at 12:06

GoogleCodeExporter commented 8 years ago
Hi Angelo,

It fix the problem, thank you very much!

Dolors

Original comment by dolma...@gmail.com on 20 Jun 2013 at 9:48

GoogleCodeExporter commented 8 years ago
Hi Dolors;

OK that's cool. I close this issue.

Regards Angelo 

Original comment by angelo.z...@gmail.com on 20 Jun 2013 at 12:34