I think I have run into a pretty bad bug in namespace handling in Closure XML. Of course, I may just be using the code wrongly.
I am using the 2007-02-18 tarball of cxml on a piece of XML code from RFC 4741 (netconf protocol):
(defvar example "<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <my-own-method xmlns="http://example.net/me/my-own/1.0%5C%22%3E <my-first-parameter>14</my-first-parameter> <another-parameter>fred</another-parameter> </my-own-method> </rpc>")
I run
(defvar p-example (cxml:parse-stream (make-string-input-stream example) cxml-xmls:make-xmls-builder)))
This is the result:
(("rpc" (("xmlns" "urn:ietf:params:xml:ns:netconf:base:1.0") ("message-id" "101")) " " ("my-own-method" (("xmlns" "http://example.net/me/my-own/1.0")) " " ("my-first-parameter" NIL "14") " " ("another-parameter" NIL "fred") " ") " "))
It should have been something like
((("rpc" . "urn:ietf:params:xml:ns:netconf:base:1.0") (("xmlns" "urn:ietf:params:xml:ns:netconf:base:1.0") (("message-id" . "urn:ietf:params:xml:ns:netconf:base:1.0") "101")) " " (("my-own-method" . "http://example.net/me/my-own/1.0") (("xmlns" "http://example.net/me/my-own/1.0")) " " (("my-first-parameter" . "http://example.net/me/my-own/1.0) NIL "14") " " (("another-parameter" . "http://example.net/me/my-own/1.0) NIL "fred") " ") " "))
There seems to be not one, but two problems. First, the parser or the builder ignores the rule that the scope of an xmlns attribute starts from the tag of the element in which it is included. Second, (and that is probably the builder) fail to apply the default namespace to internal elements.
FYI, XMLS has the approximately the same kind of bug. So has the PXML suite from Franz. It is evidently something that is a bit tough to get right. Maybe because it involves two scans of a <> construction - you really don't know the namespace of tags and attributes until you have parsed the entire <> construction and located the zero-or-one "xmlns=" and the zero-one-or-many "xmlns:<name>=" attributes.
best regards