[XML-SIG] Re: XML-SIG digest, Vol 1 #1505 - 6 msgs

Michael Schneider michael.l.schneider@eds.com
Mon, 16 Dec 2002 12:48:28 -0500


http://pdweb.sdrc.com/users/scmikes/Compiler/DefineCompileLinkFlags.xml


----- Original Message -----
From: <xml-sig-request@python.org>
To: <xml-sig@python.org>
Sent: Monday, December 16, 2002 12:00 PM
Subject: XML-SIG digest, Vol 1 #1505 - 6 msgs


> Send XML-SIG mailing list submissions to
> xml-sig@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.python.org/mailman/listinfo/xml-sig
> or, via email, send a message with subject or body 'help' to
> xml-sig-request@python.org
>
> You can reach the person managing the list at
> xml-sig-admin@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of XML-SIG digest..."
>
>
> Today's Topics:
>
>    1. Article: "A Python & XML Companion" (Uche Ogbuji)
>    2. Re: py2exe and switching from PyXML 4Suite (Mike Olson)
>    3. Re: py2exe and switching from PyXML 4Suite (Uche Ogbuji)
>    4. Re: py2exe and switching from PyXML 4Suite (Anders Bruun Olsen)
>    5. Re: py2exe and switching from PyXML 4Suite (Uche Ogbuji)
>    6. xmlproc relative dirs for DTD (Remy C. Cool)
>
> --__--__--
>
> Message: 1
> To: 4suite@lists.fourthought.com, xml-sig@python.org
> From: Uche Ogbuji <uche.ogbuji@fourthought.com>
> Date: Sun, 15 Dec 2002 10:15:23 -0700
> Subject: [XML-SIG] Article: "A Python & XML Companion"
>
> http://www.xml.com/pub/a/2002/12/11/py-xml.html
>
> I offers updates and notes on Python & XML, by Jones and Drake.
>
>
> --
> 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
>
>
>
>
> --__--__--
>
> Message: 2
> Subject: Re: [XML-SIG] py2exe and switching from PyXML 4Suite
> From: Mike Olson <Mike.Olson@fourthought.com>
> To: Uche Ogbuji <Uche.Ogbuji@fourthought.com>
> Cc: xml-sig@python.org
> Date: 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
>
>
>
> --__--__--
>
> Message: 3
> From: Uche Ogbuji <uche.ogbuji@fourthought.com>
> To: Mike Olson <Mike.Olson@fourthought.com>
> cc: xml-sig@python.org
> Subject: Re: [XML-SIG] py2exe and switching from PyXML 4Suite
> Date: Sun, 15 Dec 2002 14:25:04 -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)
>
> I think my generator approach would be faster, but this XPath approach has
the
> advantage of working in Python 2.0 and 2.1.  Mine is 2.2+.
>
>
> --
> Uche Ogbuji                                    Fourthought, Inc.
> http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
> A Python & XML Companion - http://www.xml.com/pub/a/2002/12/11/py-xml.html
> XML class warfare - http://www.adtmag.com/article.asp?id=6965
> MusicBrainz  metadata -
http://www-106.ibm.com/developerworks/xml/library/x-thi
> nk14.html
>
>
>
>
> --__--__--
>
> Message: 4
> Date: Mon, 16 Dec 2002 07:04:14 +0100
> From: Anders Bruun Olsen <anders@bruun-olsen.net>
> To: xml-sig@python.org
> Subject: Re: [XML-SIG] py2exe and switching from PyXML 4Suite
>
> On Sun, Dec 15, 2002 at 02:25:04PM -0700, Uche Ogbuji wrote:
> > > > 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)
> > I think my generator approach would be faster, but this XPath approach
has the
> > advantage of working in Python 2.0 and 2.1.  Mine is 2.2+.
>
> Okay, I have now read up on iterators and generator - WOW! that's so
> cool!.. I immediately rewrote the search part of my program that had
> been giving me problems - with generators it just works perfectly and
> the code is so much simpler!
>
> I have implemented Uche's generators now and the function that loads an
> XML file into my programs internal format has now gone from 6-7 seconds
> load time to 1-2 second for the 219Kb XML file I am using for testing on
> my Athlon XP 1800+.
>
> Now - my program also saves it's data to disk by creating a dom and
> filling it with the right nodes and then writing it to disk with
> PrettyPrint (which takes over 20 seconds on my machine with the 219Kb
> file). I am sure this can be done much faster with 4Suite somehow,
> but how?
>
> right now I use xml.dom.implementation to create the empty dom, I am
> betting it is possible to do the same using domlette, I just can't grok
> how without a little helping hand :)
>
> Also it would be great if there was a way to ditch PrettyPrint as I
> would then be completely rid of PyXML, which seems to be giving py2exe
> some problems.
>
> Once again, thanks for the help so far, you guys are great! :)
>
> --
> Anders
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GCS/O d--@ s:+ a-- C++ $UL+++ P++ L+++ E- W+ N(+) o K? w O- M-- V
> PS+ PE@ Y+ PGP+ t 5 X R+ tv+ b+ DI+++ D+ G e- h !r y?
> ------END GEEK CODE BLOCK------
> PGPKey: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8BFECB41
>
>
> --__--__--
>
> Message: 5
> From: Uche Ogbuji <uche.ogbuji@fourthought.com>
> To: xml-sig@python.org
> Subject: Re: [XML-SIG] py2exe and switching from PyXML 4Suite
> Date: Mon, 16 Dec 2002 06:55:59 -0700
>
> > On Sun, Dec 15, 2002 at 02:25:04PM -0700, Uche Ogbuji wrote:
> > > > > 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)
> > > I think my generator approach would be faster, but this XPath approach
has the
> > > advantage of working in Python 2.0 and 2.1.  Mine is 2.2+.
> >
> > Okay, I have now read up on iterators and generator - WOW! that's so
> > cool!.. I immediately rewrote the search part of my program that had
> > been giving me problems - with generators it just works perfectly and
> > the code is so much simpler!
> >
> > I have implemented Uche's generators now and the function that loads an
> > XML file into my programs internal format has now gone from 6-7 seconds
> > load time to 1-2 second for the 219Kb XML file I am using for testing on
> > my Athlon XP 1800+.
>
> Generators do absolutely rock.  I'm glad you got a good opportunity to
learn
> them as a side effect of trying to figure out Python/XML.
>
>
> > Now - my program also saves it's data to disk by creating a dom and
> > filling it with the right nodes and then writing it to disk with
> > PrettyPrint (which takes over 20 seconds on my machine with the 219Kb
> > file). I am sure this can be done much faster with 4Suite somehow,
> > but how?
>
> Rather than
>
> from xml.dom.ext import PrettyPrint
>
> use
>
> from Ft.Xml.Domlette import PrettyPrint
>
> Domlette's PrettyPrint is written in C (with Python fall-back), and is
much
> faster.
>
> > right now I use xml.dom.implementation to create the empty dom, I am
> > betting it is possible to do the same using domlette, I just can't grok
> > how without a little helping hand :)
>
> Ouch.  So you're using 4DOM, not Domlette, which is probably a bigger
reason
> for slow performance than PrettyPrint
>
> Instead of
>
> xml.dom.implementation
>
> Use
>
> from Ft.Xml.Domlette import implementation
>
> Again I must warn you that Domlette approximates DOM and is not a full
DOM.
> You already found the lack of getElementsByTagName.  There are other
subtle
> differences.  That having been said, I have not run into a situation where
> Domlette is not a suitable DOM substitute.
>
>
> > Also it would be great if there was a way to ditch PrettyPrint as I
> > would then be completely rid of PyXML, which seems to be giving py2exe
> > some problems.
>
> Well, the above would remove dependency from PyXML.  However, I think we
would
> all like at least a report of the problems py2exe is having with PyXML,
since
> it would be nice if that combo worked.
>
> > Once again, thanks for the help so far, you guys are great! :)
>
> I'm glad we've been of help.
>
> We would in turn be grateful at some point if you were to write up some of
> your experiences and techniques in order to help others through the same
> issues.
>
>
> --
> Uche Ogbuji                                    Fourthought, Inc.
> http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
> A Python & XML Companion - http://www.xml.com/pub/a/2002/12/11/py-xml.html
> XML class warfare - http://www.adtmag.com/article.asp?id=6965
> MusicBrainz  metadata -
http://www-106.ibm.com/developerworks/xml/library/x-thi
> nk14.html
>
>
>
>
> --__--__--
>
> Message: 6
> From: "Remy C. Cool" <dev-xml@smartology.nl>
> Reply-To: dev-xml@smartology.nl
> Organization: Smartology
> To: xml-sig@python.org
> Date: Mon, 16 Dec 2002 17:02:49 +0100
> Subject: [XML-SIG] xmlproc relative dirs for DTD
>
> This is not a real xmlproc problem, but maybe someone has run into the
> same or similar problem.
>
> I have a script that gets xml data via a command line argument. The
> xml data gets stored as a fileobject using StringIO .. so far so
> good. But then xmlproc complains that it can't resolve the relative
> URI. Is it possible to 'give' the StringIO fileobject a virtual path
> so that DTD's can be resolved?
>
> Regards,
> Remy Cool
>
>
>
>
>
> End of XML-SIG Digest