Created
February 22, 2018 20:43
-
-
Save jasom/2aefd041ccafc5108040ec06f4959c1a to your computer and use it in GitHub Desktop.
Lisp XML namespaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cxml:parse #P"foo.xml" (cxml-xmls:make-xmls-builder)) ;;=> | |
;(("stream" . "http://etherx.jabber.org/streams") | |
; ((("lang" . "http://www.w3.org/XML/1998/namespace") "en") | |
; (("stream" . "http://www.w3.org/2000/xmlns/") | |
; "http://etherx.jabber.org/streams") | |
; ("version" "1.0") ("to" "localhost") | |
; ((NIL . "http://www.w3.org/2000/xmlns/") "jabber:client")) | |
; " | |
; " | |
; (("iq" . "jabber:client") | |
; (("id" "b70fb10f-f68a-4be2-9d40-99ced9e338c6") ("type" "set")) " | |
; " | |
; (("bind" . "urn:ietf:params:xml:ns:xmpp-bind") | |
; (((NIL . "http://www.w3.org/2000/xmlns/") | |
; "urn:ietf:params:xml:ns:xmpp-bind")) | |
; " | |
; " | |
; (("resource" . "urn:ietf:params:xml:ns:xmpp-bind") NIL "Gajim") " | |
; ") | |
; " | |
; ") | |
; " | |
; " | |
; (("iq" . "jabber:client") | |
; (("id" "8350ebb5-4f16-4b34-8780-b7acaefe6c47") ("type" "set") | |
; ("from" "jmiller@localhost/Gajim")) | |
; " | |
; " | |
; (("session" . "urn:ietf:params:xml:ns:xmpp-session") | |
; (((NIL . "http://www.w3.org/2000/xmlns/") | |
; "urn:ietf:params:xml:ns:xmpp-session"))) | |
; " | |
; ") | |
; " | |
;") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<stream:stream xmlns="jabber:client" to="localhost" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xml:lang="en" > | |
<iq type="set" id="b70fb10f-f68a-4be2-9d40-99ced9e338c6"> | |
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"> | |
<resource>Gajim</resource> | |
</bind> | |
</iq> | |
<iq from="jmiller@localhost/Gajim" type="set" id="8350ebb5-4f16-4b34-8780-b7acaefe6c47"> | |
<session xmlns="urn:ietf:params:xml:ns:xmpp-session" /> | |
</iq> | |
</stream:stream> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let ((h (cxml-xmls:make-xmls-builder))) | |
(klacks:with-open-source (s (cxml:make-source #P"foo.xml")) | |
(klacks:serialize-source s h)) | |
(sax:end-document h)) | |
;; => | |
;(("stream" . "http://etherx.jabber.org/streams") | |
; ((("lang" . "http://www.w3.org/XML/1998/namespace") "en") | |
; (("stream" . "http://www.w3.org/2000/xmlns/") | |
; "http://etherx.jabber.org/streams") | |
; ("version" "1.0") ("to" "localhost") | |
; ((NIL . "http://www.w3.org/2000/xmlns/") "jabber:client")) | |
; " | |
; " | |
; (("iq" . "jabber:client") | |
; (("id" "b70fb10f-f68a-4be2-9d40-99ced9e338c6") ("type" "set")) " | |
; " | |
; (("bind" . "urn:ietf:params:xml:ns:xmpp-bind") | |
; (((NIL . "http://www.w3.org/2000/xmlns/") | |
; "urn:ietf:params:xml:ns:xmpp-bind")) | |
; " | |
; " | |
; (("resource" . "urn:ietf:params:xml:ns:xmpp-bind") NIL "Gajim") " | |
; ") | |
; " | |
; ") | |
; " | |
; " | |
; (("iq" . "urn:ietf:params:xml:ns:xmpp-bind") | |
; (("id" "8350ebb5-4f16-4b34-8780-b7acaefe6c47") ("type" "set") | |
; ("from" "jmiller@localhost/Gajim")) | |
; " | |
; " | |
; (("session" . "urn:ietf:params:xml:ns:xmpp-session") | |
; (((NIL . "http://www.w3.org/2000/xmlns/") | |
; "urn:ietf:params:xml:ns:xmpp-session"))) | |
; " | |
; ") | |
; " | |
;") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s-xml:parse-xml-file "foo.xml") ;=> | |
;((|stream|:|stream| :|xmlns| "jabber:client" :|to| "localhost" :|version| "1.0" | |
; :|xmlns:stream| "http://etherx.jabber.org/streams" XML:|lang| "en") | |
; ((|jabber.client|:|iq| :|type| "set" :|id| | |
; "b70fb10f-f68a-4be2-9d40-99ced9e338c6") | |
; ((NS-1:|bind| :|xmlns| "urn:ietf:params:xml:ns:xmpp-bind") | |
; (NS-1:|resource| "Gajim"))) | |
; ((|jabber.client|:|iq| :|from| "jmiller@localhost/Gajim" :|type| "set" :|id| | |
; "8350ebb5-4f16-4b34-8780-b7acaefe6c47") | |
; ((NS-2:|session| :|xmlns| "urn:ietf:params:xml:ns:xmpp-session")))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(with-open-file (s "foo.xml") (xmls:parse s)) ;=> | |
;(("stream" . "http://etherx.jabber.org/streams") | |
; (("lang" "en") ("version" "1.0") ("to" "localhost")) | |
; (("iq" . "jabber:client") | |
; (("id" "b70fb10f-f68a-4be2-9d40-99ced9e338c6") ("type" "set")) | |
; (("bind" . "urn:ietf:params:xml:ns:xmpp-bind") NIL | |
; (("resource" . "urn:ietf:params:xml:ns:xmpp-bind") NIL "Gajim"))) | |
; (("iq" . "urn:ietf:params:xml:ns:xmpp-bind") | |
; (("id" "8350ebb5-4f16-4b34-8780-b7acaefe6c47") ("type" "set") | |
; ("from" "jmiller@localhost/Gajim")) | |
; (("session" . "urn:ietf:params:xml:ns:xmpp-session") NIL))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The second "iq" element should be in the "jabber:client" ns as that is the xmlns declared by its parent element. With xmls and klacks however, the default namespace does not reset after the "bind" element closes. s-xml and cxml's SAX interface gets it right.