[XML-SIG] Writing DOM-neutral code
Mike Olson
Mike.Olson@fourthought.com
05 Dec 2001 18:40:43 -0700
On Wed, 2001-12-05 at 13:36, Rich Salz wrote:
> 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
Here is the class definition I have for a NamedNodeMap in 4DOM. Has
someone changed it recently?
class NamedNodeMap(UserDict.UserDict):
def __init__(self, ownerDoc=None):
UserDict.UserDict.__init__(self)
>
> 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.
It should work. 4XPath, 4xslt, 4XLink, 4XPointer, 4RDF, etc all support
4DOM, pDomlette, cDomlette and to some extent minidom.
Mike
>
> 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
>
> _______________________________________________
> XML-SIG maillist - XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig
--
Mike Olson Principal Consultant
mike.olson@fourthought.com +1 303 583 9900 x 102
Fourthought, Inc. http://Fourthought.com
4735 East Walnut St, http://4Suite.org
Boulder, CO 80301-2537, USA
XML strategy, XML tools, knowledge management