StimVinsh / xdocreport

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

"if else " messing up with FieldsExtractor #91

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Very simple If else condition
2.  Report parses fine  
3. Will throw exception when try to extract field from report using the 
following :

    final public static Collection<String> getFields(IXDocReport report)throws XDocReportExcep
tion{
        Collection<String> names = new TreeSet<String>();
        FieldsExtractor<FieldExtractor> extractor = new FieldsExtractor<FieldExtractor>();
        report.extractFields(extractor);
        List<FieldExtractor> fields = extractor.getFields();
        for(FieldExtractor field : fields) names.add(field.getName());
        return names;
    }

What is the expected output? What do you see instead?
The parser should just work

fr.opensagres.xdocreport.core.XDocReportException: 
org.apache.velocity.runtime.parser.TemplateParseException: Encountered "#else" 
at word/document.xml[line 2, column 3153]
Was expecting one of:
    "(" ...
    <RPAREN> ...
    <ESCAPE_DIRECTIVE> ...
    <SET_DIRECTIVE> ...
    "##" ...
    "\\\\" ...
    "\\" ...
    <TEXT> ...
    "*#" ...
    "*#" ...
    "]]#" ...
    <STRING_LITERAL> ...
    <END> ...
    <IF_DIRECTIVE> ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <WORD> ...
    <BRACKETED_WORD> ...
    <IDENTIFIER> ...
    <DOT> ...
    "{" ...
    "}" ...
    <EMPTY_INDEX> ...

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

Please provide any additional information below.
Please contact me if you can not reproduce this issue.
The following seems to work 
#if   
#elseif
#end  

Original issue reported on code.google.com by mingkem...@yahoo.com on 13 Mar 2012 at 9:04

Attachments:

GoogleCodeExporter commented 8 years ago
fr.opensagres.xdocreport.core.XDocReportException: 
org.apache.velocity.runtime.parser.TemplateParseException: Encountered "#else" 
at word/document.xml[line 2, column 37923]
Was expecting one of:
    "(" ...
    <RPAREN> ...
    <ESCAPE_DIRECTIVE> ...
    <SET_DIRECTIVE> ...
    "##" ...
    "\\\\" ...
    "\\" ...
    <TEXT> ...
    "*#" ...
    "*#" ...
    "]]#" ...
    <STRING_LITERAL> ...
    <END> ...
    <IF_DIRECTIVE> ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <WORD> ...
    <BRACKETED_WORD> ...
    <IDENTIFIER> ...
    <DOT> ...
    "{" ...
    "}" ...
    <EMPTY_INDEX> ...

        at fr.opensagres.xdocreport.template.velocity.VelocityTemplateEngine.extractFields(VelocityTemplateEngine.java:193)
        at fr.opensagres.xdocreport.template.AbstractTemplateEngine.extractFields(AbstractTemplateEngine.java:190)
        at fr.opensagres.xdocreport.document.AbstractXDocReport.extractFields(AbstractXDocReport.java:617)
        at fr.opensagres.xdocreport.document.AbstractXDocReport.extractFields(AbstractXDocReport.java:595)

Original comment by mingkem...@yahoo.com on 13 Mar 2012 at 9:18

GoogleCodeExporter commented 8 years ago
Hi,

Before studying your problem, I would like tell you that FieldsExtractor is 
very very simple and so very limited. FieldsExtractor is enable to find fields 
which starts with $ but doesn't manage list, if condition etc....

FieldsExtractor  was just created for teh WebApp demo (upload a document and 
retrieves fields), but in real reporting model (fields) is known.

So my question is why do you wish using FieldsExtractor? I don't know if 
Velocity/Freemarker gives you the capability to parse condition, list (must 
study that).

Regards Angelo

Original comment by angelo.z...@gmail.com on 13 Mar 2012 at 9:35

GoogleCodeExporter commented 8 years ago
Hi, Angelo,

I understand that it is not going to be 100% correct in identifying
the variables.  It is acceptable that when you get a exception, just 
silently ignore that, and continue onto next $variable.  It is better
than throwing an exception.  Because most people would expect
that this is not going to be 100% correct (condition etc might not 
be parse-able),  it is ok that if you miss one or two because of a 
parsing error. But please do not abort the whole function.

It is kinda useful for me to know the variables list.  For example,
if I know that there is a "employee_list.name", then I can set up
"employee_list" automatically, to be used in a loop within a table.

People tend to design the templates first, instead of thinking about
the variables  list first.  So there could be many variables in the 
template. It is very useful for me to identify the variable list from
the template.

P.S.,  the dotm Macro does not seem to work on Mac Word2011.
Even it works, it is kinda useless for me as is.  When making the
template, a designer works almost the same way as writing a 
ASP / JSP script.   A better macro should be similar to a JSP IDE. 

Thanks

Original comment by mingkem...@yahoo.com on 14 Mar 2012 at 4:45

GoogleCodeExporter commented 8 years ago
Hi,

>People tend to design the templates first, instead of thinking about
>the variables  list first.
I think it's a very bad idea. It's better to design your model and after you 
can generate fields.xml to use with Macro (even if I know that it should be 
improved).

But I understand your opinion. People design at first the template but after I 
think model should be designed at first according to the the template. So you 
need have support for fields used in the template. 

It should be very cool if you help me with that with some contribution and 
JUnit. I would like support Freemarker and Velocity both. I think we should do 
that step by steap list what we wish support: 

* fields used in condition
* fields used in a list (I think it's very important that).
* other?

For the dotm Macro, please create a new issue for that and explains the problem 
(can you display fields in the dialog? can you preview? etc..) My problem is 
that I have not Mac, so if you can help us for that, it should be cool.

So any contribution are welcome!

Regards Angelo

Original comment by angelo.z...@gmail.com on 14 Mar 2012 at 8:30

GoogleCodeExporter commented 8 years ago
Hi, Angelo,

I am using it for pretty sophisticated reports (100s of pages).  
What happens, is that, a designer go through all the pages,
replacing dynamic content one by one with merge field. 

I am certainly indebted to contribute in every possible way.  I 
will get familiar to the source code.

I am not so sure about having to support BOTH Freemarker AND 
Velocity. It is important that we do ONE thing, and get ONE thing 
RIGHT.  It will be very impressive if we can add IDE support for 
merge field.

Will detail my findings with Mac.

Thanks

Original comment by mingkem...@yahoo.com on 14 Mar 2012 at 4:20

GoogleCodeExporter commented 8 years ago
Hi Minkov,

For your information I have improved FieldsExtractor with Velocity to manage 
#foreach (I have redeployed the webapp demo so you can play with it with upload 
http://xdocreport.opensagres.cloudbees.net/loadReport.jsp).

For Freemarker, I have not found solution to manage that. I think it's very 
important to support the both because some people uses XDocReport with Velocity 
(like JBoss Seam  Report) and some people uses Freemarker (like Nuxeo).

You tell me about IDE support. You mean to develop for instance an Eclipse 
Plugin to design docx, odt report? If it that, I can tell you that we will not 
develop that. Why?

1) Very hard to develop a designer.
2) Not the goal of XDocReport.

The first goal of XDocReport is to design your report with MS Word or 
OpenOffice. A lot of consumer who wishs to integrate reporting feature in their 
application wish modify the report (like change a static image). With powerfull 
report engine like JasperReport, Bird, etc you must use a complex IDE designer.

In a business application you have simple reporting (like Resume) => goal of 
XDocReport

and complex reporting (group by your data in complex table, manage complex 
header/footer, etc) => goal of JasperReport, Bird, etc...

You tell me that you have complex reporting, and you tell me about IDE, perhaps 
XDocReport is not the well solution for your need? Why not use JasperReport, 
Bird, etc project for your need?

We know that tooling with MS Macro/OOOo extension should be improved, but we 
have not intention to develop an IDE for that.

Regards Angelo

Original comment by angelo.z...@gmail.com on 15 Mar 2012 at 8:47

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 1 Sep 2012 at 12:08