[XML-SIG] PyXML XPath woes

luis miguel morillas morillas at posta.unizar.es
Sat Feb 7 20:19:23 EST 2004

	Asunto: [XML-SIG] PyXML XPath woes
	Fecha: sáb, feb 07, 2004 at 07:33:37 +0000

Citando a  Matt Patterson (list-matt at reprocessed.org):
> Hello,
> I've got an XML file in which I want to locate all elements with the 
> attribute boundary set to 'true'. I use the following XPath with 4DOM:
> //*[@boundary='true']
> like so:
> boundaryFinder = Compile("//*[@boundary='true']")
> context = Context(self.document)
> # evaluate the expression and get a nodeList
> boundaryNodes = boundaryFinder.evaluate(context)
> But the results of the XPath do not return all the nodes which match!
Doesn't it?
I get 47 nodes with http://www.emdash.co.uk/opf/tmp603_12_%20Chldrns_edction.e12

from Ft.Xml import Domlette
from Ft.Xml.XPath.Context import Context
from Ft.Xml.XPath import Compile


doc = reader.fromStream(open('tmp603_12_%20Chldrns_edction.e12'))

bf = Compile("//*[@boundary='true']")

result = bf.evaluate(context)

print len(result)

> The project I'm working on involves paginating large XML files in an 
> arbitrary way using DOM Range. To figure out where the page boundaries 
> lie I'm using XPath to locate the nodes which cause a new page to 
> start. The boundary="true" attributes are added in a pre-processing 
> step

Very interesting!!


Luis Miguel

No a las patentes de software en Europa

More information about the XML-SIG mailing list