> I've just quickly checked the FreeMarker documention about XML processing. My impression is that if you have a simpler XML structure and output, FreeMarker is a better choice. On the other hand, I'm not sure it has support for XPath selectors in the FreeMarker declarative XML processing, which is usually the best approach for more complex XML structures.
I see reference to using XPath in Freemarker's declaritive approach at the bottom of this page http://freemarker.sourceforge.net/docs/xgui_declarative_details.htmlalthough I can't find any examples "But in this case don't forge that in XPath expressions (we didn't used any in the example) the default XML namespace must be accessed with an explicit D: since names without prefix always refer to nodes with no XML namespace in XPath. Also note that with the same logic as with imperative XML processing, the name of handlers for elements that has no XML namespace is N:elementName if (and only if) there is a default XML namespace. However, for nodes that are not of type element (such as text nodes), you never use the N prefix in the handler name, because those nodes are free of the idea of XML namespaces. So for example, the handler for text nodes is always just @text." On Tuesday, 20 March 2012, Thiago H. de Paula Figueiredo <thiag...@gmail.com> wrote: > On Tue, 20 Mar 2012 09:28:39 -0300, Lance Java <lance.j...@googlemail.com> wrote: > >>> Actually, XSLT makes sense when the source document is XML already. >> >> I disagree, both freemarker and XSLT need to parse the XML input into some form of DOM object before applying a transformation to it. Do you agree >> that XSLT templates are far more verbose than Freemarker templates? > > No. :) I've just quickly checked the FreeMarker documention about XML processing. My impression is that if you have a simpler XML structure and output, FreeMarker is a better choice. On the other hand, I'm not sure it has support for XPath selectors in the FreeMarker declarative XML processing, which is usually the best approach for more complex XML structures. > >>> Sorry, Lance, my flame war detector failed to detect it in this thread. >> >> Sorry for the inconvenience. :P >> >> I'm not trying to start a flame war here. > > I haven't seen any here too, but I just wanted to continue the joke. :) > >> It just seems that people blindly >> often choose XSLT for XML transformations without considering freemarker. > > Agreed. The more options known, the better the choice. > >> In this thread, trsvax mentions using JAXB to convert java objects to XML >> so that they can be passed to XSLT which parses them into DOM objects. Why not just pass the java objects to freemarker and avoid XML all together? > > I thought the Java to XML part was strange too, unless the declarative way is better for the described scenario. Maybe that's the case, as the technology used to generate PDF is FO, which is XML-based, but then I'm talking about something I barely know . . . > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br >