Re: XDocReport, IDE support (Was: Re: Anybody with deeper OSGi bundle can comment on freemarker.jar OSGification?)

Angelo zerr <[email protected]> Mon, 3 Jun 2013 14:29:45 +0200
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <CAKLdLg_Cz-u2HHt6OgwewQ3cqO+WCDpzuCo0QcSdLqnFHE3W5g@mail.gmail.com>
2013/6/3 Daniel Dekany <[email protected]>

> Monday, June 3, 2013, 11:16:59 AM, Angelo zerr wrote:
>
> > Hi Daniel
> >
> >> Sure. You should provide a project description, less than 250
> >>characters.
> >
> > Ok I will send you that.
> >
> >>Any ideas that would make FreeMarker a better fit for these kind of
> >>templates that you enter right into Word/LO?
> > docx/odt are a zip which contains several XML entries (ex: for docx
> > word/document.xml, for odt content.xml)
> > XDocReport unzip docx/odt and load some XML entries (
> > word/document.xml, for odt content.xml) with Freemarker.
> > So we have a Template instance for some XML entries. When report
> > must be generated, XDocReport uses Freemarker to merge
> > XML entries with Java context and create a new zip with XML entries
> merged.
> > Freemarker works great.
>
> I mostly meant issues with FreeMarker that has effect on the end-user.
> Like if FreeMarker could to this-and-that, then you could add
> this-and-that extra feature, or the end user wouldn't run into certain
> error repeatedly, or at least would understand easier what's going
> on... etc.
>
> For example, what happens if the users enters `x && y`? Won't Word/OO
> corrupt that to `x &amp;&amp; y`?
>
> Yes you are right. To fix this problem, XDocReport preprocess each XML
entries to transform  `x &amp;&amp; y` to `x && y`
before loading it in the Freemarker Template.


> > The only thing that I don't like is our extractor fields feature
> > (it extract Freemarker fields name from docx).See method
> > extractVariables
> >
> https://code.google.com/p/xdocreport/source/browse/template/fr.opensagres.xdocreport.template.freemarker/src/main/java/fr/opensagres/xdocreport/template/freemarker/FreemarkerTemplateEngine.java
> >
> > I find this code is awfull:
> >
> > if ( DOLLAR_VARIABLE.equals(
> > templateElement.getClass().getSimpleName() ) )
>
> You mean, the problem here is that the AST is not (fully) exposed
> through a public API. Well... once it's exposed, we have backward
> compatibility constraints there too (and BC is already a very
> problematic roadblock for FM). So at the very least the parser had to
> be cleaned up before that. (Or maybe, it should remain internal, but
> with some public tooling API that lets you traverse a higher level
> view of the template, hiding some of the implementation details.
> Although keeping that up to date is a lot fiddling in itself.)
>
> Otherwise I don't 100% get what that part does. You extract the the
> expression from inside the ${...} and make it the name of a filed. But
> if I have `${1 + x}` then will the field name will be "1 + x", which
> is maybe unintended.
>

Fields extractor is very basic. If you have `${1 + x}`, field name will be
1 + x (and not x).
But fields extractor was developped just to upload a docx and retrieves
fields.See demo at http://xdocreport.opensagres.cloudbees.net/loadReport.jsp


>
> And does the user really have to create a field to enter an
> interpolation, or can he just enter ${expression} anywhere? (The point
> of ${expression} instead of the $varName of Velocity is that ${...} is
> a safe enough delimiter in itself in most applications.)
>

It must create a field to enter an interpolation or directive. Why? Because
docx and odt doesn't escape the typed content that you set in a field.

If you are interested, you can play with our online demo
http://xdocreport.opensagres.cloudbees.net/index.jsp

>
> >> But it's on the Central Maven Repository for a long time. Or what do
> >>you mean?
> > yes you are right, but it doesn't support OSGi.
>
> Of course, starting from 2.3.20, the Maven artifact will be an OSGi
> bundle.
>

Great! We will switch to it.


>
> >> Yes, better tooling would mean a lot to FreeMarker.
> > cool.
> >
> >> Was that also a problem with FM 3?
> > Jonathan Revusky told me that it's possible to manage tolerant
> > parser with FreeCC, but he has gaven Freemarker.
> > I have not time to study FreeCC and I would like find people who
> > are interested to help me to develop DLTK Freemarker.
>
> He has also gave up on FreeCC as far as I know. But I suppose it can
> be implemented with JavaCC too.
>

Perhaps, but the question is who can do that?


>
> > An other idea that I had had, is to manage Freemarker with
> > CodeMirro( Javascript editor which manages any mode). I have works a
> > lot with CodeMirror for completion and syntax error.
> > For instance you can find sample with Velocity
> > http://codemirror-java.opensagres.cloudbees.net/velocity.html the
> > syntax error is managed on server side. We could do the same thing
> > with Freemarker and better manage debugging feature.
>
> BTW, does Velocity have an error-tolerant AST builder?
>

I think it's the same problem than Freemarker. You can see it in my demo
http://codemirror-java.opensagres.cloudbees.net/velocity.html
The editor displays just one error even (the first found error) even if
they are several errors.

>
> > Regards Angelo
> >
> >
> >
> >
> >
> > 2013/6/3 Daniel Dekany <[email protected]>
> > Monday, June 3, 2013, 1:21:04 AM, Angelo zerr wrote:
> >
> >> Hi everybody,
> >>
> >> @Daniel : for OSGi topic, it seems your bnd is good. We use
> >> Freemarker with XDocReport which is Java reporting tool (you design
> >> your report with MS Word or OpenOffice and you use
> >> Velocity/Freemarker syntax to replace simple, list value) and
> >> generate docx or odt report (and convert it with PDF or XHTML)
> >> (Daniel, you can add XDocReport to the Powered By if you are agree,
> >> thank's!).
> >
> > Sure. You should provide a project description, less than 250
> > characters.
> >
> > Any ideas that would make FreeMarker a better fit for these kind of
> > templates that you enter right into Word/LO?
> >
> >> We have an Eclipse RCP/RAP demo (which works on OSGi
> >> context) and in this demo we use the com.springsource.freemarker
> >> bundles and the MANIFEST.MF looks like your bnd.
> >>
> >> It's out of scope of this post, but I think it should really cool if
> >> Freemarker could be hosted on the central maven repository (like
> >> springsource have done). Many project uses Maven (we use it in
> >> XDocReport) and I could simply switch to the "official" Freemarker
> >> dependency.
> >
> > But it's on the Central Maven Repository for a long time. Or what do
> > you mean?
> >
> > <dependency>
> >   <groupId>org.freemarker</groupId>
> >   <artifactId>freemarker</artifactId>
> >   <version>...</version>
> > </dependency>
> >
> >> @Debugging feature : I think today Freemarker is very mature and
> >> stable, but I think tooling about Freemarker misses.
> >
> > Yes, better tooling would mean a lot to FreeMarker. I was rather
> > unhappy about all that happened with your work on the DLTK plugin due
> > to the cancelling of FM3.
> >
> >> It exists a JBoss Freemarker plugins but I think we can do better
> >> than this plugin like managing debugger, preview, etc. I had started
> >> this work with Eclipse DLTK at
> >>
> http://sourceforge.net/p/freemarker/code/HEAD/tree/sandbox/org.eclipse.dltk.freemarker/
> >> You can see doc at
> >>
> http://sourceforge.net/p/freemarker/code/HEAD/tree/sandbox/org.eclipse.dltk.freemarker/docs/
> >> and for debug I have used the Debugger Freemarker to manage DBGP
> protocol.
> >>
> >> But I have gaven my work because of the Freemarker parser which is
> >> not tolerant (it crashes as soon as it  finds an error). With editor
> >> context, parser must be tolerant (to build an AST even if there are
> errors).
> >
> > Was that also a problem with FM 3? Anyway, if you still want to work
> > on that plugin, we could revive this topic, and then I could do
> > something about it. Something that this time makes into a release.
> >
> >> IMHO, I think Freemarker should be improved  for tools support like :
> >>
> >>  * manage tolerant parser.
> >>  * improve debugger (like DBGP debugger).
> >>
> >> Regards Angelo
> >
> > --
> > Thanks,
> >  Daniel Dekany
> >
> >
>
> --
> Thanks,
>  Daniel Dekany
>
>

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2

_______________________________________________
FreeMarker-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel