Package: python-lxml Version: 2.1.5-1 Severity: normal
$ python lookup.py Exception exceptions.AssertionError: u'Tried to unregister unknown proxy' in <Element value at 82fa7ac> ignored ['v1'] The problem does not occur if I somehow keep the another XML document alive while evaluating the XPath expression. -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (900, 'unstable'), (500, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.29-1-686 (SMP w/2 CPU cores) Locale: LANG=C, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages python-lxml depends on: ii libc6 2.9-12 GNU C Library: Shared libraries ii libxml2 2.7.3.dfsg-1 GNOME XML libraryii libxslt1.1 1.1.24-2 XSLT processing library - runtime ii python 2.5.4-2 An interactive high-level object-o
ii python-central 0.6.11 register and build utility for Pyt ii zlib1g 1:1.2.3.3.dfsg-13 compression library - runtime python-lxml recommends no packages. Versions of packages python-lxml suggests: pn python-lxml-dbg <none> (no description available) -- no debconf information -- Jakub Wilk
from __future__ import with_statement
from lxml import etree
def lookup(dummy, xml_file, id):
with file(xml_file) as xml_file:
xml = etree.parse(xml_file)
return xml.xpath('id(%r)' % id)
ns = etree.FunctionNamespace(None)
ns['lookup'] = lookup
root = etree.XML('<dummy/>')
doc = etree.ElementTree(root)
print root.xpath("lookup('table.xml', 'k1')/value/text()")
table.xml
Description: XML document

