Hi, I have an XML file which I'd like to validate. I also want to populate a hash table based on the contents of the document -- ideally at the same time.
Long story short: I've setup a validation routine similar to JING's ValidationDriver. What I now want to do is this: if an element is valid, I'd like to perform some application logic based on its contents and populate my hash table. However, I can't extend the Validator object because it gets created by my Schema object and there's no (easy) way I can tell it to construct a different validator. If I try to construct my own Validator it turns into a real nightmare as I then need a Pattern object for the constructor and understanding how to build one of those requires diving into the internals of JING (I spent an hour or so tracing through the code but eventually gave up). So I thought, OK, no problem. I'll just create a new proxy ContentHandler which encapsulates one of JING's Validators and pass that to my XMLReader. I figured each time one of my ContentHandler methods is invoked I can invoke the JING's Validator method of the same name and thus check if the element is valid before I perform my stuff. But I'm foiled again because JING's Validators implement not just the ContentHandler interface but also ErrorHandler so I never know if there was an error or not because the startElement method (for instance) calls directly to the error method. Since there's no separation of concerns between handling the content and dealing with errors I'm left with no real option except to parse the document once for validity and then parse it again with a custom ContentHandler to do my stuff. Is there any way out of this mess?
