[XML-SIG] XPath in Python 2

Mike Olson Mike.Olson@fourthought.com
Mon, 10 Jul 2000 17:04:47 -0600


Paul Prescod wrote:
> 
> Uche Ogbuji wrote:
> >
> > ..
> >
> 
> > I don't know.  I agree that most people don't need XPath's zoo of axes, but I
> > think predicates would be sorely missed very quickly.
> 
> It depends on the target audience. You seldom miss what you've never
> used and most Python users have never used XPath or XSLT. Anyhow, the
> more important point is that much of what predicates do could be done in
> Python code. For you and I, that would grate, but if you compare it to
> what they've got now (even in DOM, Pyxie, qp_xml, etc.) it's not like
> they are losing something.

Sure, but you could also do all of it in python.  Some of the tings you
can do with predicates will be much more efficent in XPath/XPattern,
then do a bit in XPath, and a bit in python.  however, you wouldn't have
access to the internal steps.  Imagine

/EMPLOYEES/EMPLOYEE[@position="Manager"]/SPOUSE[size(CHILDREN) >
3]/CHILDREN[@age > 18]

Without predicates, you would get back a list of children, then you need
to see which of those has a parent whose married to a manager, then
remove all children who are from families with less then 3 siblings, and
then all children with an age less then 18. 

Somewhat of a contrived example, but hopefully you see my point


Mike

> --
>  Paul Prescod - Not encumbered by corporate consensus
> "Computer Associates is expected to come in with better than expected
> earnings." Bob O'Brien, quoted in
>         - http://www.fool.com/news/2000/foth000316.htm
> 
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://www.python.org/mailman/listinfo/xml-sig

-- 
Mike Olson				 Principal Consultant
mike.olson@fourthought.com               (303)583-9900 x 102
Fourthought, Inc.                         http://Fourthought.com 
Software-engineering, knowledge-management, XML, CORBA, Linux, Python