[XML-SIG] Writing DOM-neutral code

Rich Salz rsalz@zolera.com
Wed, 05 Dec 2001 15:36:59 -0500


I know that on the face of it that's a silly question -- it's the whole
point of having a standard (albeit crappy:) API.

If I have an element, e, then
	Using pyxml (4dom) dom, e.attributes is a list
	Using cDomlette, e.attributes is a dictionary;
		e.attributes.values() is what is needed

Within PyXML I have xml/dom/ext/c14n.py, and I also have ZSI
(pywebsvcs.sf.net), and I want to support both the full rich dom and the
lean and mean fast one.

Anyone have any general approaches to this?  Right now, I'm about to
check this change into c14n.py:

+def _attrs(E):
+    '''Get the sequence of attribute nodes, even if the DOM uses a
+    dictionary.'''
+
+    a = E.attributes
+    if not a: return []
+    if type(a) == type({}): return a.values()
+    return a
+

?
	/r$

-- 
Zolera Systems, Your Key to Online Integrity
Securing Web services: XML, SOAP, Dig-sig, Encryption
http://www.zolera.com