StimVinsh / xdocreport

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

Cannot use simple/double quote with ODT and for Freemarker interpolation #64

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
## Escaping in FreeMarker

In my usit tests, I have an ODT that contains this :

------------- START ------------------
${doc['dc:title']}

Author : ${doc['dc:creator']}

Contributors : 
[#list doc['dc:contributors'] as contributor]
 ${contributor}
[/#list]

Creation Date : ${doc['dc:created']}

Subjects :

[#list doc['dc:subjects'] as subject]

${subject}

[/#list]
------------- END ------------------

Here doc object is the DocumentModel object of Nuxeo.
The 'dc:subjects' is the name of the property.
So I need to use simple quotes for the field name.

This works ok :

 - in standard freemarker (we use it in our web rendering layer)

 - in JODReport

But it fails in XDocReport because of a FreeMarker error : 

freemarker.core.ParseException: Encountered "&" at line 3, column 4402.

The & is the one of the ' entity that represents the '.

The issue can easily be solved if I insert a real field like explained in your 
doc : and use for example ${doc["dc:title"]}
=> use " instead of '

The real issue is that it work only for real fields and for now I did not find 
a way to do something like :
[#list doc['dc:subjects'] as subject]
${subject}
[/#list]

=> here I can not use doc["dc:subjects"] because " are automatically escaped by 
OpenOffice.

Original issue reported on code.google.com by angelo.z...@gmail.com on 10 Jan 2012 at 11:42

GoogleCodeExporter commented 8 years ago
Problem is fixed in the XDocReport 0.9.4. Now you can use simple quote (ex: 
${doc['dc:title']}) or double quote (ex : ${doc["dc:title"]}) in a text input.

There are 2 TestCase : 

* for Freemarker : 
http://code.google.com/p/xdocreport/source/browse/integrationtests/fr.opensagres
.xdocreport.core.test/src/test/java/fr/opensagres/xdocreport/document/odt/prepro
cessor/ODTPreprocessorTextInputWithFreemarkerTestCase.java

* for Velocity : 
http://code.google.com/p/xdocreport/source/browse/integrationtests/fr.opensagres
.xdocreport.core.test/src/test/java/fr/opensagres/xdocreport/document/odt/prepro
cessor/ODTPreprocessorTextInputWithVelocityTestCase.java

Original comment by angelo.z...@gmail.com on 10 Jan 2012 at 12:09

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 10 Jan 2012 at 2:19