[XML-SIG] XPath and Zope's ParsedXML DOM
Jeremy Kloth
jeremy.kloth@fourthought.com
Tue, 10 Jul 2001 13:07:41 -0600
From: "Martijn Faassen" <faassen@vet.uu.nl>
> Hi there,
>
> I've been trying to make XPath work with Zope's DOM implementation,
> ParsedXML. In the process I've discovered some incompatibilities in
> XPath that I had to hack around.
>
> The problem is as follows. ParsedXML uses DOM nodes that are
> descendants of ExtensionClass. This means that type(node) !=
types.InstanceType.
>
Instead of doing the check every time, I implemented a more lazy approach to
it. Additionally, the performance hit happens only the first time through.
def _strUnknown(object):
# Allow for non-instance DOM node objects
if hasattr(object, 'nodeType'):
# Add this type to the mapping for next time through
_strConversions[type(object)] = _strInstance
return _strInstance(object)
return
and change type types.ListType entry in _strConversions to:
types.ListType : lambda x: x and _strConversions.get(type(x[0]),
_strUnknown)(x[0]) or '',
--
Jeremy Kloth Consultant
jeremy.kloth@fourthought.com +1 303 583 9900 x 105
Fourthought, Inc. http://fourthought.com
4735 East Walnut St, Boulder, CO 80301, USA
XML strategy, XML tools (http://4suite.org), knowledge management