Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Stream XPath Processor Algorithm

I am developing XML Stream XPath Processor in java, What i am expecting to do is

1.) Split the Xpath into elements and store the elements in a queue.

2.) Go through the XML file by SAX and in it's startElement() method check the current element is in the queue.

3.) If it is in the queue, then store the element data in characters(...) method.

Is my approach correct? I am stuck in first step because, it is hard to check all the xPath commands to divide the elements. Is there is any easy way to implement first step?

like image 324
sugeesh Avatar asked Jun 07 '26 13:06

sugeesh


1 Answers

If you define a simple subset of XPath, for example

("/" name ( "[" integer "]" )? )*

Then parsing it isn't very difficult, and matching it against the events in a SAX stream isn't very difficult either. (Though namespaces are always a challenge).

But the way you have phrased the question makes me suspect that even this simplified problem requires more experience and/or computer science knowledge than you currently possess: the fact that you are already asking questions like this suggests to me that you don't have any idea of the scale of the challenge you have set yourself.

like image 93
Michael Kay Avatar answered Jun 10 '26 02:06

Michael Kay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!