Building stuff

SAX is how object models like DOM and STP plug into cxml's parser: You parse a document using cxml:parse, and as a SAX handler you specify one of the "builder" objects provided by the object model. As a result you get the newly built object tree:

Example using DOM:

CL-USER> (cxml:parse "<foo>bar</foo>" (cxml-dom:make-dom-builder))
;;; note: ignored return values not shown in trace output.
 0: (SAX:START-ELEMENT #<RUNE-DOM::DOM-BUILDER> NIL "foo" "foo" NIL)
 0: (SAX:CHARACTERS #<RUNE-DOM::DOM-BUILDER> "bar")
 0: (SAX:END-ELEMENT #<RUNE-DOM::DOM-BUILDER> NIL "foo" "foo")

;;; Here comes the DOM document:
 0: (SAX:END-DOCUMENT #<RUNE-DOM::DOM-BUILDER>)
 0: returned #<RUNE-DOM::DOCUMENT @ #x26e81b12>

#<RUNE-DOM::DOCUMENT @ #x26e81b12>

For the next examples we'll use the DOM alternative STP:

CL-USER> (cxml:parse "<foo>bar</foo>" (stp:make-builder))
;;; no trace output this time, you know how it works

#.(CXML-STP-IMPL::DOCUMENT
   :CHILDREN '(#.(CXML-STP:ELEMENT
                  :CHILDREN '(#.(CXML-STP:TEXT :DATA "bar"))
                  :LOCAL-NAME "foo")))
Read on to find out how XML serialization fits in with all of this.