Any Alternative approach to SAXParser which validates even after occuring Fatal error
I have a requirement like this :
I need to read events from log files and validate them. i.e whether the events logged in log files are according to their timestamps or some other parameter. If there is any mistake in logging sequence, then i need to report it to QA team.
Approach i used was to read log file, create an xml from it based on events and validate the开发者_JAVA技巧m. But the main problem i am facing with this SaxParser is that, if there is any mistake in any one sequence, it stops validating. But my requirement says i need to validate remaining part of xml too.
Example log file :
Time:20111022,Event:StartA
Time:20111022,Event:StartB
Time:20111022,Event:EndB
Time:20111022,Event:EndA
XML Created from this is :
<A>
<B></B>
</A>
Problem : Consider this scenario :
<A>
<B>
<C>
</B>
</A>
<A>
<B>
<C></C>
</A>
< C > is not correctly closed in 1st block, so SAXparser throws error and stops validating. It does not report < /B > missing in second block. SO is there any alternative approach to tackle this problem. I have tried building error handler too, but once it catches fatal error, parsing stops
I recommend that you consider another approach. Maybe a stack can be used to ensure that log entries are properly nested and it will be easy to clear it and continue when/if an error is detected.
精彩评论