2007-08-05

A new data structure for XML

As mentioned earlier, I set out to define an alternative to the W3C's Document Object Model, inspired heavily by Java's XOM, but made for Common Lisp.

The result is STP, a data structure for XML that is full-featured and uses CLOS, but is more natural than DOM and gets namespaces right. Its implementation cxml-stp is available as an add-on library for Closure XML.

(For most purposes, it should be preferable to other alternatives, but DOM fans -- in case there are any -- can be assured that DOM support in cxml will not go away either.)

Read more about STP in the tutorial.

2 comments:

Jack Unrue said...

I did a quick pass through your tutorial, and my impression is that STP is very nice! I have a particular task (authoring DocBook/XSL content) that might be easier in Lisp than writing grotty XML by hand. So I plan to do some experimenting where I generate the DocBook stuff via STP and see how it goes.

Unknown said...

Wow, that looks surprisingly similar to what I've made in Factor, though I don't do as many well-formedness checks when people are constructing their own XML, and nodes don't link to their parents. The documentation is at http://factorcode.org/responder/help/show-help?topic=xml%20intro and processing functions are documented at http://factorcode.org/responder/help/show-help?topic=xml%20utils . It's much less mature than CXML, of course, in particular with respect to incremental parsing.