1.1 --- a/libxml2dom/xmpp.py Sat Sep 29 22:34:24 2007 +0000
1.2 +++ b/libxml2dom/xmpp.py Sat Sep 29 22:40:31 2007 +0000
1.3 @@ -54,6 +54,8 @@
1.4 import select
1.5 import base64 # for auth elements
1.6
1.7 +# XMPP-related namespaces.
1.8 +
1.9 XMPP_BIND_NAMESPACE = "urn:ietf:params:xml:ns:xmpp-bind"
1.10 XMPP_CLIENT_NAMESPACE = "jabber:client"
1.11 XEP_0022_EVENT_NAMESPACE = "jabber:x:event"
1.12 @@ -62,6 +64,18 @@
1.13 XMPP_SESSION_NAMESPACE = "urn:ietf:params:xml:ns:xmpp-session"
1.14 XMPP_STREAMS_NAMESPACE = "http://etherx.jabber.org/streams"
1.15
1.16 +# Default namespace bindings for XPath.
1.17 +
1.18 +default_ns = {
1.19 + "bind" : XMPP_BIND_NAMESPACE,
1.20 + "client" : XMPP_CLIENT_NAMESPACE,
1.21 + "event": XEP_0022_EVENT_NAMESPACE,
1.22 + "register" : XMPP_REGISTER_NAMESPACE,
1.23 + "sasl" : XMPP_SASL_NAMESPACE,
1.24 + "session" : XMPP_SESSION_NAMESPACE,
1.25 + "stream" : XMPP_STREAMS_NAMESPACE
1.26 + }
1.27 +
1.28 class XMPPImplementation(libxml2dom.Implementation):
1.29
1.30 "Contains an XMPP-specific implementation."
1.31 @@ -141,25 +155,18 @@
1.32
1.33 class XMPPNode(libxml2dom.Node):
1.34
1.35 - "Convenience modifications to nodes specific to libxml2dom.svg."
1.36 + "Convenience modifications to nodes specific to libxml2dom.xmpp."
1.37
1.38 def xpath(self, expr, variables=None, namespaces=None):
1.39
1.40 """
1.41 Evaluate the given 'expr' using the optional 'variables' and
1.42 - 'namespaces'. If not otherwise specified, the "stream" prefix will be
1.43 - bound to XMPP_STREAMS_NAMESPACE as defined in this module.
1.44 + 'namespaces'. If not otherwise specified, the prefixes given in the
1.45 + module global 'default_ns' will be bound as in that dictionary.
1.46 """
1.47
1.48 - ns = {
1.49 - "bind" : XMPP_BIND_NAMESPACE,
1.50 - "client" : XMPP_CLIENT_NAMESPACE,
1.51 - "event": XEP_0022_EVENT_NAMESPACE,
1.52 - "register" : XMPP_REGISTER_NAMESPACE,
1.53 - "sasl" : XMPP_SASL_NAMESPACE,
1.54 - "session" : XMPP_SESSION_NAMESPACE,
1.55 - "stream" : XMPP_STREAMS_NAMESPACE
1.56 - }
1.57 + ns = {}
1.58 + ns.update(default_ns)
1.59 ns.update(namespaces or {})
1.60 return libxml2dom.Node.xpath(self, expr, variables, ns)
1.61
1.62 @@ -169,6 +176,9 @@
1.63
1.64 pass
1.65
1.66 +class XMPPElement(XMPPNode):
1.67 + pass
1.68 +
1.69 class XMPPAuthElement(XMPPNode):
1.70
1.71 "An XMPP auth element."
1.72 @@ -383,9 +393,6 @@
1.73 class XMPPStreamElement(XMPPNode):
1.74 pass
1.75
1.76 -class XMPPElement(XMPPNode):
1.77 - pass
1.78 -
1.79 # Classes providing XMPP session support.
1.80
1.81 class SessionTerminated(Exception):