applied patch from Anthony Carrico providing Python bindings for the
* python/libxml.c python/libxml.py: applied patch from Anthony Carrico
providing Python bindings for the Canonicalization C14N support.
Daniel
diff --git a/python/libxml.py b/python/libxml.py
index 4d643f9..0c3ba6c 100644
--- a/python/libxml.py
+++ b/python/libxml.py
@@ -349,6 +349,48 @@
return libxml2mod.saveNodeTo(self._o, file, encoding, format)
#
+ # Canonicalization routines:
+ #
+ # nodes: the node set (tuple or list) to be included in the
+ # canonized image or None if all document nodes should be
+ # included.
+ # exclusive: the exclusive flag (0 - non-exclusive
+ # canonicalization; otherwise - exclusive canonicalization)
+ # prefixes: the list of inclusive namespace prefixes (strings),
+ # or None if there is no inclusive namespaces (only for
+ # exclusive canonicalization, ignored otherwise)
+ # with_comments: include comments in the result (!=0) or not
+ # (==0)
+ def c14nMemory(self,
+ nodes=None,
+ exclusive=0,
+ prefixes=None,
+ with_comments=0):
+ if nodes:
+ nodes = map(lambda n: n._o, nodes)
+ return libxml2mod.xmlC14NDocDumpMemory(
+ self.get_doc()._o,
+ nodes,
+ exclusive != 0,
+ prefixes,
+ with_comments != 0)
+ def c14nSaveTo(self,
+ file,
+ nodes=None,
+ exclusive=0,
+ prefixes=None,
+ with_comments=0):
+ if nodes:
+ nodes = map(lambda n: n._o, nodes)
+ return libxml2mod.xmlC14NDocSaveTo(
+ self.get_doc()._o,
+ nodes,
+ exclusive != 0,
+ prefixes,
+ with_comments != 0,
+ file)
+
+ #
# Selecting nodes using XPath, a bit slow because the context
# is allocated/freed every time but convenient.
#