Like other XML parsers written in Lisp, CXML can work with documents represented as list structures. The specific model implemented by cxml is compatible with the xmls parser. Xmls list structures are a simpler and faster alternative to full DOM document trees. They also serve as an example showing how to implement user-defined document models as an independent layer over the the base parser (c.f. xml/xmls-compat.lisp in the cxml distribution). However, note that the list structures do not include all information available in DOM documents (notably, things like dom:parent-node) and are sometimes more difficult to work with because of that since many DOM functions cannot be implemented on them.
Example:
(cxml:parse-file "test.xml" (cxml-xmls:make-xmls-builder))
Use this function to serialize XMLS data. For example, we could define a replacement for xmls:write-xml like this:
(defun write-xml (stream node &key indent) (let ((sink (cxml:make-character-stream-sink stream :canonical nil :indentation indent))) (cxml-xmls:map-node sink node)))
The node list's car can also be a cons of local name and namespace prefix ns.
fixme: It is unclear to me how namespaces are meant to work in xmls, since xmls documentation differs from how xmls actually works in current releases. Usually applications need to know both the namespace prefix and the namespace URI. We currently follow the xmls implementation and use the namespace prefix instead of following its documentation which shows the URI. We do not follow xmls in munging xmlns attribute values. Attributes themselves have namespaces and it is not clear to me how that works in xmls.