Converting between representations
We now know how to build STP from SAX, and to generate SAX from STP. We also saw that the full STP -> SAX -> STP roundtrip works.
More usefully, we can convert STP to the traditional W3C DOM in the same fashion.
(cxml's W3C DOM functions predate the newer STP model, and are a little arcane, e.g. the order of arguments is sometimes swapped compared to the modern APIs. But the idea is the same: cxml-dom:make-dom-builder is the equivalentto stp:make-builder. And dom:map-document is a little like stp:serialize.)
(defun stp-to-dom (stp) (stp:serialize stp (cxml-dom:make-dom-builder))) (defun dom-to-stp (dom) (dom:map-document (stp:make-builder) dom))