In response to XML data bindings, static languages, dynamic languages Bob Hutchison posted some thoughts. As I used Amara as the kernel of my demonstrations, Bob used his project xampl as the kernel of his. He introduces xampl in another entry which was inspired by my own article on EaseXML.
Xampl is a an XML data binding. As Bob writes:
Secondly, there are versions of xampl for Java and Common Lisp. I’ve got an old (summer 2002) version for Ruby that needs updating (I wrote the xampl-pp pull parser to support this experiment).
Bob says that Xampl also deals with things that Elliotte Harold mentions as usual scourges for Java data bindings: mixed content, repeated elements, omitted elements, and element order. Of course these things should be food and drink to any XML tool, and I'm glad folks are finally plugging such gaping holes. Eric van der Vlist is also in the game with TreeBind, and it seems some Java tools try to wriggle out of the pinch by using XQuery.
Based on Bob's snippets, Xampl looks handy. Rather verbose, but no more so
than Java pretty much requires. One thing that strikes me in Bob's
examples is that Xampl appears to require and create a bogon namespace
(http://www.xampl.com/labelsExample
). It seems maybe it has something
to do with Java packaging or something, but regardless of the role of
this fake namespace, the XML represented by Xampl in Bob's snippets is
not the same as the XML in the original source examples. An
unprefixed element in a namespace is of course not the same thing as an
element in the null namespace. I would not accept any tool that involves
such a mix-up. It's quite possible that Xampl does not do so, and I'm
just misunderstanding Bob's examples.
Bob provides Xampl code to match the EaseXML snippets in my article. Similarly to how EaseXML requires Python framework code, Xampl requires XML framework code. Since "XML situps" have been on the wires lately, they come to mind for a moment, but hey, if you're already processing XML with Xampl, I suppose you might not flinch at one more XML. I will point out that Amara does not require any framework code whatsoever besides the XML itself, not even an XML schema. It effectively provides dynamic code generation.
Xampl turns XML constructs into Java getters, e.g. html.getHead()
.
Amara uses the Python convention of properties rather than getters and
setters, so you have html.head
, and you can even assign to this
property in order to mutate the XML. Xampl looks neat. The things that
turn me off are largely things that are pretty much inevitable in Java,
not least the very large amount of code generated by the binding. It
supports XPath, as Amara does, and provides a "rhino" option to expose
XML objects through Javascript, which offers you a bit more of the
flexibility of Python (I don't know how much overhead to expect from
Javascript through Java through XML, but it's a question I'd be quick to
ask as a user).
It's good to have projects such as Xampl and Treebind and Nux. I'd rather use Python tools such as Amara, Gnosis and GenerateDS, but Java has the visibility and it's good for people to be aware that XML does not necessarily require greater imprisonment of expression than what comes with the application language. You don't need to accept crazy idioms and stifling limitations in matters as fundamental as mixed content and element ordering. XML and sanity can coexist.