1.1 --- a/README.txt Sun Jan 26 21:53:15 2014 +0100
1.2 +++ b/README.txt Sun Jan 26 22:55:18 2014 +0100
1.3 @@ -94,6 +94,10 @@
1.4 * Changed the parsing of HTML documents retrieved using parseURI to use the
1.5 libxml2 network retrieval support.
1.6 * Exposed LSException and XIncludeException through libxml2dom.
1.7 + * Changed the origin of specific namespace defaults in XPath operations,
1.8 + initialising document-specific default namespaces in the document object
1.9 + instead of acquiring such defaults from the module namespace in the xpath
1.10 + method invocation.
1.11
1.12 New in libxml2dom 0.5 (Changes since libxml2dom 0.4.7)
1.13 ------------------------------------------------------
2.1 --- a/libxml2dom/__init__.py Sun Jan 26 21:53:15 2014 +0100
2.2 +++ b/libxml2dom/__init__.py Sun Jan 26 22:55:18 2014 +0100
2.3 @@ -3,7 +3,7 @@
2.4 """
2.5 DOM wrapper around libxml2, specifically the libxml2mod Python extension module.
2.6
2.7 -Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2012, 2013 Paul Boddie <paul@boddie.org.uk>
2.8 +Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2012, 2013, 2014 Paul Boddie <paul@boddie.org.uk>
2.9
2.10 This program is free software; you can redistribute it and/or modify it under
2.11 the terms of the GNU Lesser General Public License as published by the Free
2.12 @@ -523,8 +523,9 @@
2.13 """
2.14
2.15 ns = {}
2.16 - ns.update(default_ns)
2.17 - ns.update(namespaces or {})
2.18 + ns.update(self.ownerDocument.namespaces)
2.19 + if namespaces:
2.20 + ns.update(namespaces)
2.21 result = Node_xpath(self._node, expr, variables, ns)
2.22 if isinstance(result, str):
2.23 return to_unicode(result)
2.24 @@ -588,10 +589,17 @@
2.25 VAL_FALSE = 6
2.26 VAL_UNKNOWN = 7
2.27
2.28 - def __init__(self, node, impl):
2.29 + def __init__(self, node, impl, namespaces=None):
2.30 self._node = node
2.31 self.implementation = self.impl = impl
2.32 self.error_handler = libxml2dom.errors.DOMErrorHandler()
2.33 + self.namespaces = {}
2.34 + self._update_namespaces([default_ns, namespaces])
2.35 +
2.36 + def _update_namespaces(self, additional_namespaces):
2.37 + for namespaces in additional_namespaces:
2.38 + if namespaces:
2.39 + self.namespaces.update(namespaces)
2.40
2.41 # Standard DOM properties and their implementations.
2.42
3.1 --- a/libxml2dom/soap.py Sun Jan 26 21:53:15 2014 +0100
3.2 +++ b/libxml2dom/soap.py Sun Jan 26 22:55:18 2014 +0100
3.3 @@ -6,7 +6,7 @@
3.4
3.5 See: http://www.w3.org/TR/2007/REC-soap12-part0-20070427/
3.6
3.7 -Copyright (C) 2007, 2008 Paul Boddie <paul@boddie.org.uk>
3.8 +Copyright (C) 2007, 2008, 2014 Paul Boddie <paul@boddie.org.uk>
3.9
3.10 This program is free software; you can redistribute it and/or modify it under
3.11 the terms of the GNU Lesser General Public License as published by the Free
3.12 @@ -66,19 +66,6 @@
3.13
3.14 "Convenience modifications to nodes specific to libxml2dom.soap."
3.15
3.16 - def xpath(self, expr, variables=None, namespaces=None):
3.17 -
3.18 - """
3.19 - Evaluate the given 'expr' using the optional 'variables' and
3.20 - 'namespaces'. If not otherwise specified, the prefixes given in the
3.21 - module global 'default_ns' will be bound as in that dictionary.
3.22 - """
3.23 -
3.24 - ns = {}
3.25 - ns.update(default_ns)
3.26 - ns.update(namespaces or {})
3.27 - return libxml2dom.Node.xpath(self, expr, variables, ns)
3.28 -
3.29 def add_or_replace_element(self, new_element):
3.30
3.31 """
3.32 @@ -163,6 +150,16 @@
3.33
3.34 "A SOAP document fragment."
3.35
3.36 + def __init__(self, node, impl, namespaces=None):
3.37 +
3.38 + """
3.39 + Initialise the document with the given 'node', implementation 'impl',
3.40 + and 'namespaces' details.
3.41 + """
3.42 +
3.43 + libxml2dom._Document.__init__(self, node, impl, None)
3.44 + self._update_namespaces([default_ns, namespaces])
3.45 +
3.46 def _envelope(self):
3.47 return (self.xpath("env:Envelope|SOAP-ENV:Envelope") or [None])[0]
3.48
4.1 --- a/libxml2dom/svg.py Sun Jan 26 21:53:15 2014 +0100
4.2 +++ b/libxml2dom/svg.py Sun Jan 26 22:55:18 2014 +0100
4.3 @@ -5,7 +5,7 @@
4.4 See: http://www.w3.org/TR/SVGMobile12/python-binding.html
4.5 See: http://www.w3.org/TR/SVGMobile12/svgudom.html
4.6
4.7 -Copyright (C) 2007, 2008, 2012 Paul Boddie <paul@boddie.org.uk>
4.8 +Copyright (C) 2007, 2008, 2012, 2014 Paul Boddie <paul@boddie.org.uk>
4.9
4.10 This program is free software; you can redistribute it and/or modify it under
4.11 the terms of the GNU Lesser General Public License as published by the Free
4.12 @@ -33,6 +33,10 @@
4.13
4.14 SVG_NAMESPACE = "http://www.w3.org/2000/svg"
4.15
4.16 +default_ns = {
4.17 + "svg" : SVG_NAMESPACE
4.18 + }
4.19 +
4.20 comma_wsp = re.compile("\s*,\s*|\s+")
4.21
4.22 TYPE_MISMATCH_ERR = 17
4.23 @@ -737,20 +741,9 @@
4.24
4.25 class SVGNode(libxml2dom.Node):
4.26
4.27 - "Convenience modifications to nodes specific to libxml2dom.svg."
4.28 -
4.29 - def xpath(self, expr, variables=None, namespaces=None):
4.30 + "An SVG-specific node."
4.31
4.32 - """
4.33 - Evaluate the given 'expr' using the optional 'variables' and
4.34 - 'namespaces'. If not otherwise specified, the "svg" prefix will be bound
4.35 - to SVG_NAMESPACE as defined in this module.
4.36 - """
4.37 -
4.38 - namespaces = namespaces or {}
4.39 - if not namespaces.has_key("svg"):
4.40 - namespaces["svg"] = SVG_NAMESPACE
4.41 - return libxml2dom.Node.xpath(self, expr, variables, namespaces)
4.42 + pass
4.43
4.44 # NOTE: DocumentEvent is from DOM Level 3 Events.
4.45 # NOTE: EventSystem is a special libxml2dom.events class.
4.46 @@ -759,14 +752,15 @@
4.47
4.48 "An SVG-specific document node."
4.49
4.50 - def __init__(self, node, impl):
4.51 + def __init__(self, node, impl, namespaces=None):
4.52
4.53 """
4.54 Initialise the document with the given 'node', implementation 'impl',
4.55 and global (SVGGlobal) details.
4.56 """
4.57
4.58 - libxml2dom._Document.__init__(self, node, impl)
4.59 + libxml2dom._Document.__init__(self, node, impl, None)
4.60 + self._update_namespaces([default_ns, namespaces])
4.61 self.global_ = self.impl.get_global(self) # parent
4.62
4.63 class SVGElement(SVGNode, EventTarget, TraitAccess, ElementTraversal): # NOTE: SVGNode instead of Element.
5.1 --- a/libxml2dom/xmpp.py Sun Jan 26 21:53:15 2014 +0100
5.2 +++ b/libxml2dom/xmpp.py Sun Jan 26 22:55:18 2014 +0100
5.3 @@ -10,7 +10,7 @@
5.4 See: http://www.xmpp.org/rfcs/rfc3920.html
5.5 See: http://www.xmpp.org/rfcs/rfc3921.html
5.6
5.7 -Copyright (C) 2007, 2009 Paul Boddie <paul@boddie.org.uk>
5.8 +Copyright (C) 2007, 2009, 2014 Paul Boddie <paul@boddie.org.uk>
5.9
5.10 This program is free software; you can redistribute it and/or modify it under
5.11 the terms of the GNU Lesser General Public License as published by the Free
5.12 @@ -159,26 +159,23 @@
5.13
5.14 class XMPPNode(libxml2dom.Node):
5.15
5.16 - "Convenience modifications to nodes specific to libxml2dom.xmpp."
5.17 -
5.18 - def xpath(self, expr, variables=None, namespaces=None):
5.19 + "An XMPP-specific node."
5.20
5.21 - """
5.22 - Evaluate the given 'expr' using the optional 'variables' and
5.23 - 'namespaces'. If not otherwise specified, the prefixes given in the
5.24 - module global 'default_ns' will be bound as in that dictionary.
5.25 - """
5.26 -
5.27 - ns = {}
5.28 - ns.update(default_ns)
5.29 - ns.update(namespaces or {})
5.30 - return libxml2dom.Node.xpath(self, expr, variables, ns)
5.31 + pass
5.32
5.33 class XMPPDocument(libxml2dom._Document, XMPPNode):
5.34
5.35 "An XMPP document fragment."
5.36
5.37 - pass
5.38 + def __init__(self, node, impl, namespaces=None):
5.39 +
5.40 + """
5.41 + Initialise the document with the given 'node', implementation 'impl',
5.42 + and 'namespaces' details.
5.43 + """
5.44 +
5.45 + libxml2dom._Document.__init__(self, node, impl, None)
5.46 + self._update_namespaces([default_ns, namespaces])
5.47
5.48 class XMPPElement(XMPPNode):
5.49 pass