2005-02-28

Templating for XML

How do you create XML programmatically? I've been fed up with the templating options known to me for a number of reasons:
  • JSP: JSP does not directly target XML. You have to use custom tags to do escaping. The spec regards markup as the exceptional case: (paraphrased) "in the unlikely event you want to do xml, ... use something like c:out". There also is no JSP implementation that neither uses a web container, the filesystem nor compilation, although the JSP 2.0 API and EL would allow for such scriptless, interpreted templates.
  • Velocity: much easier to embed, but still targeted at producing characters, not infoset.
  • XSLT: garantuees well-formed output. However, takes XML as input where I'm looking for something that accepts a map of Java beans. Xalan Java extensions make some things possible but it's not a natural integration.

There may be other options, but I bet they're either plaintext or XML transformations. I'm looking for XML production out of beans. So I decided to roll my own, "axt", "attributes-only xml templates". The project at https://axt.dev.java.net has its approval pending. A copy from the description:

"A template processor for producing XML. It takes XML templates as input, garantuees well-formed output unlike JSP or Velocity, is designed to process beans as a data model unlike XSLT. axt uses the OGNL expression language for expressions. axt exclusively uses namespaced attributes as template annotations and no elements, like Zope's tal."

I have to go now but I'll write more about it later.

Posted by Matthias at 9:54.10. Comment: blog@mernst.org
Edited on: 2005-02-28 10:13.44