The DOM implementation

CXML implements the DOM Level 2 Core interfaces.  For details on DOM, please refer to the specification.

Parsing into DOM

To parse an XML document into a DOM tree, use the SAX parser with a DOM builder as the SAX handler. Example:

(cxml:parse-file "test.xml" (dom:make-dom-builder))

Function DOM:MAKE-DOM-BUILDER ()
Create a SAX handler which builds a DOM document.

Serializing DOM

The technique used to serialize a DOM document is to use a SAX serialization sink as the argument to dom:map-document, which generates SAX events for the DOM tree.

In addition, there are convenience functions like unparse-document as a thin wrapper around map-document.

Function DOM:MAP-DOCUMENT (handler document &key include-xmlns-attributes include-default-values include-doctype)
Traverse a DOM document and call SAX functions as if an XML representation of the document was processed by a SAX parser.

Keyword arguments:

Function CXML:UNPARSE-DOCUMENT (document stream &rest keys)
Function CXML:UNPARSE-DOCUMENT-TO-OCTETS (document &rest keys) => vector

Serialize a DOM document object. These convenience functions are wrappers around dom:map-document.

Keyword arguments are passed on to the sink. C.f. cxml:make-octet-vector-sink.

Notes:

DOM/Lisp mapping

Note that there is no "standard" DOM mapping for Lisp.

DOM is specified in CORBA IDL, but it refrains from using object-oriented IDL features, allowing for a much more natural Lisp implemenation than the the ordinary IDL/Lisp mapping would.  Differences between CXML's DOM and the direct IDL/Lisp mapping: