dbarra / xdocreport

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

MergeFields getValue from docx #295

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I am trying to check the values in the MergeFields in docx before doing any 
treatment like analyzing the template and tell the user to change fix the 
template before proceeding any replacement of field or conversion.
I started looking at docx4j for that but while i am using xdocreport and want 
to know if there is any functionality provided by it for the kind of purpose.

Thank you,
Bilel

Original issue reported on code.google.com by oueslatibilel216@gmail.com on 12 Sep 2013 at 9:28

GoogleCodeExporter commented 8 years ago
Hi Bilel,

The values of MergeField comes from Java context, so why you cannot check this 
value before using XDocReport?

Regards Angelo

Original comment by angelo.z...@gmail.com on 12 Sep 2013 at 9:32

GoogleCodeExporter commented 8 years ago
Hi Angelo,

I mean, I want to upload the docx template in DB before even thinking about 
doing anything, i mean check the syntax of the MergField if it correctly 
Freemarker syntax or not, you are telling me that i can have the syntax via the 
context using XDocReport.

Regards,
Bilel

Original comment by oueslatibilel216@gmail.com on 12 Sep 2013 at 9:50

GoogleCodeExporter commented 8 years ago
Ok sorry I didn't understand what you wish to do. Forget my comment.

If I understand you wish to validate your "template" docx before saving it in 
your DB.

When you generate a report, you can have 2 kinds of problem : 

1) the Freemarker/Velocity syntax is bad (ex : you start a start loop with 
[#list/#foreach without the end of the loop #end)
2) you set a name field which doesn't exists ${fieldNameDontExistsInTheContext}.

You have 2 choices to do that : 

1) generate a report with hard-coded context and check if you have some errors.
2) load the report and extract the fields name of teh report with 
IXDocReport#extractFields( FieldsExtractor extractor ) and check if field name 
are known. But pay attention with the extractor, it manages simple case to 
extract field name (just ${myField} is managed).

Regards Angelo

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

GoogleCodeExporter commented 8 years ago
Hi Angelo,

Thank you for the answer.

Regards,
Bilel

Original comment by oueslatibilel216@gmail.com on 17 Sep 2013 at 5:25