hi i have been asked to code a generic file parser to parse xml and csv files...Now for the xml files i am asked to code an sax parser and then use xpath to get specific values from elements...I am fairly new to these technologies..i would like to know if i can use xpath with the SAX interface and can anyone point to some resources that i could look at... thanx paryul
Seems to me that regular xpath requires a DOM of some sort to operate and thus can't be implemented with only SAX processing. I suppose you could evaluate limited xpath expressions by keeping track of the SAX start and end element events. Life will be a lot simpler if you are not required to implement namespaces! Bill
rajagopal,bill:Thanx for your replies.I finally got more info on what im supposed to do.This parser is part of a larger code which is supposed to track files sent into an enterprise system.Now the system has CSVfiles and XML files so what we wanna do is create a generic parser for both these formats.The purpose of this parsing is only to extract certain information from the file and log it to some database so that we know where the file is in the system.The code that im supposed to design will take in the file and based on a xpath query will extract the unique data from the field and then it will be logged.My question was since ive not had time yet to read up on xpath ,can it be used in this senario with a sax parser?I think i would have to read in the xpath string,tokenize it and then code it in such a way that i read in the info when that specific element is encountered during the sax parsing.Do you have any suggestions?
Author and all-around good cowpoke
Joined: Mar 22, 2000
i would have to read in the xpath string,tokenize it and then code it in such a way that i read in the info when that specific element is encountered during the sax parsing.
I think you are on the right track there. Figuring out how to represent the xpath logic will certainly be interesting! I wonder if some sort of "rules engine" such as DROOLS or JESS would be any use or if it would just be overkill. Do you have any feeling for how complex the xpath queries may become? Bill
Joined: May 11, 2005
hey bill I think the solution i thought off might work and i also dont have to be bothered about namespaces...:-)Its still a lot of work but thanx for ur input ..really appreaciate it
Payul, I think you must be a really spiritual person to post a question like that. Am I right?
Joined: May 11, 2005
hey thanx eddy Noah.I dont really understand how you came to that conclusion !!! Could you please explain
Joined: Oct 07, 2005
hey payul, well, you said 'I am fairly new to these technologies'. only a spiritual person is so honest. are you an iscon follower, i get a feeling that you are? it takes a spiritual person to know one...