FreeMarker 2.3 introduced some powerful new facilities for XML manipulation and transformation. See the appropriate manual section for a detailed introduction. Here, we contrast FreeMarker, as an XML transformation tool with the much better-known XSLT stylesheet approach promulgated by the Worldwide Web Consortium (W3C). XSLT is a W3C recommendation for transforming XML. Its basic programming paradigm is a functional declarative programming model. Though this theoretical model is elegant and powerful -- at least for those who master it -- the fact remains that, put simply, it is not everybody's cup of tea. XSL syntax, mostly because it is an XML variant, is really quite verbose and awkward to edit. It is our opinion that using FreeMarker instead of XSLT will be a very welcome relief to most ordinary people out there. Though one's mileage always varies, it seems safe to say that FreeMarker is much less resource-intensive than comparable XSLT transformations. Our new FTL-based Docbook transformation with which we generate the FreeMarker manual is 15 times faster than the XSLT-based transformation it replaces (using SAXON) and requires 3 times less heap space. AvailabilitySince XSLT is a W3C standard, it is more widely known, there are various books in print on the topic, and various third-party implementations available in various programming languages and for various computing platforms. By contrast, FreeMarker has exactly one implementation (our own freely available open-source implementation) that runs on one platform, albeit a virtual platform -- the Java Virtual Machine (JVM). Virtually the only documentation on FreeMarker is what we provide. That said, the wider availability of literature on XSLT is, in a sense, good news and bad news. The good news is that many books on XSLT are available; the bad news is that this plethora of tutorial materials surely came into existence in large part due to the difficulty of learning and mastering XSLT. Also, we should note that the FreeMarker manual is chock full of examples and tutorials. As a practical matter, it is likely that people will be up and running, writing useful templates in FreeMarker very quickly -- a matter of days or even hours. It is unlikely that this will be the case with XSLT. That FreeMarker is (currently) tied to the JVM is not a severe constraint, since, as of this writing, there is a JVM implementation for every significant computing environment. As to the availability of competing implementations, we leave it to your judgment to consider how important this really is. FreeMarker has a highly active open-source community, and we react to bug-fixes very quickly and we are also highly responsive to requests for feature enhancements. Different Programming ModelsXSLT and FreeMarker can both be used to generate output from XML input, but they are really very different tools. FreeMarker is a template engine. As such, it is not based on any preconceived notion of the structure of the output. You provide a page template with certain embedded instructions and what is not an embedded instruction is passed through as-is to the output. By contrast, XSLT is really a tree-transformation tool; it takes an input tree and manipulates it into an output tree. The FreeMarker Template Language (FTL) is based on a much more conventional programming model -- the procedural or imperative model. You can define variables and functions. You control the flow of execution via conventional imperative constructs such as loops, if-else, and switch-case statements. XSLT is based on a functional programming model that will be quite strange and alien to most users. Computing Resource UsageAs of this writing, we do not have a wide range of comparative tests on runtime performance. However, initial indications are that FreeMarker is much, much faster than XSLT for equivalent transformation tasks. With FreeMarker 2.3pre3, we switched over from using XSLT stylesheets to generate the manual to using FreeMarker itself. The FTL-based transformation, producing almost identical output from the same input (Docbook XML) is 15 times faster than the legacy XSLT transformation using Saxon. Moreover, the FTL-based transformation requires about 4 megabytes of heap space, vs. 14 megabytes for Saxon. |
![]() |
Found broken link or other problem with this site? Report to: ddekanyREMOVEME@freemail.hu (remove the "REMOVEME" from the address) |
Page last generated: 2004-06-15 22:17:56 GMT All content on this page copyrighted by the FreeMarker project. |
![]() |
![]() |