Don't ask to ask, just ask | |
PerlMonks |
Idea for XPath implementationby Jaap (Curate) |
on Apr 01, 2003 at 09:48 UTC ( [id://247194]=perlquestion: print w/replies, xml ) | Need Help?? |
Jaap has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks, Perl needs a fast and memory efficient XPath module. The key to making a fast & memory efficient XPath processor is to find a smart data structure to derive from the XML document and keep in memory. The XPath query should then be done largely on that data structure. Idea: Suppose we build an array with values like this for each node: 'elementName,parentId,byteIndex' Where elementName is the name of the element, parentId is the arrayindex of the parent and byteIndex is the byteposition of the element in the xml document. If we have this xml document: The above xml doc would generate a data structure like this: Now if the XPath query looks like this: /colors/paprika/bad then we'd start with the last part: bad, find it in the array and see if his parent is paprika (this can be done VERY fast since we have the arrayindex of the parent). If it is paprike, look for his parent to see if it's colors. If all that's true, we have the byteIndex to look in the XML document for the content of the element. To keep it short now, are there any obvious shortcomings to this approach? Is it worth implementing? I have some optimisations in mind for this, but that would only make the story longer.
Back to
Seekers of Perl Wisdom
|
|