[XML-SIG] py2exe and switching from PyXML 4Suite

Mike Olson Mike.Olson@fourthought.com
15 Dec 2002 13:00:02 -0700


> 
> Because you're such a nice guy, I'll ditch the tease for you :-)

You can also do these much more easily using XPath...

from Ft.Xml import XPath


def getElementsByTagName(node,name)
    return XPath.evaluate(node,".//" + name)


It really does not need to be a function in this case, just inline it
where ever you need it.

Mike


> 
> from __future__ import generators
> from xml.dom import Node
> 
> 
> def doc_order_iterator(node):
>     yield node
>     for child in node.childNodes:
>         for cn in doc_order_iterator(child):
>             yield cn
>     return
> 
> 
> def doc_order_iterator_filter(node, filter_func):
>     if filter_func(node):
>         yield node
>     for child in node.childNodes:
>         for cn in doc_order_iterator_filter(child, filter_func):
>             yield cn
>     return
> 
> 
> def get_elements_by_tag_name(node, name):
>     return doc_order_iterator_filter(node, lambda n: n.nodeType == \ 
>        Node.ELEMENT_NODE and n.nodeName == name)
> 
> 
> def get_elements_by_tag_name_ns(node, ns, local):
>     return doc_order_iterator_filter(node, lambda n: n.nodeType == \ 
>        Node.ELEMENT_NODE and n.namespaceURI == ns and n.localName == local)
> 
> 
> def get_first_element_by_tag_name_ns(node, ns, local):
>     return get_elements_by_tag_name_ns(node, ns, local).next()
> 
> #etc.
> 
> 
> For a fuller discussion of the basic techniques I use here, see:
> 
> http://www-106.ibm.com/developerworks/xml/library/x-tipgenr.html
> 
> As you can see, many of the things one needs to know about PyXML and 4Suite 
> are documented, but the documents are quite poorly organized.  I've put a lot 
> of work into at least making the info available, and we are be putting some 
> work into getting it organized in our push towards 4SUite 1.0.  Don't hesitate 
> to ask, in the meantime.
> 
> 
> -- 
> Uche Ogbuji                                    Fourthought, Inc.
> http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
> Tour of 4Suite - http://www.xml.com/pub/a/2002/10/16/py-xml.html
> Proper XML Output in Python - http://www.xml.com/pub/a/2002/11/13/py-xml.html
> RSS for Python - http://www-106.ibm.com/developerworks/webservices/library/ws-p
> yth11.html
> Debug XSLT on the fly - http://www-106.ibm.com/developerworks/xml/library/x-deb
> ugxs.html
> 
> 
> 
> _______________________________________________
> 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 
PO Box 270590,                            http://4Suite.org
Louisville, CO 80027-5009, USA
XML strategy, XML tools, knowledge management