I am using: javax.xml.validation.* and org.xml.sax.SAXException to validate an xml document against a schema with repeating occurences of a parent key element sucessfully against the total xml document.
I need to link my errors to a parent element.
A simple example would be:
<Record> <KeyField>1</KeyField> <Information>info about key field 1</Information> </Record
<Record> <KeyField>2</KeyField> <Information>info about key field 2</Information> </Record
What is the most straight forward way to link the error with the <Keyfield> value as the document is being parsed?
What is the most straight forward way to to capture the parent element's child primary key value to tie it in with any errors that are parsed?
This is off the top of my head but... I have been looking into XML pipeline processing and I think you could handle the problem with a pipeline configuration. Essentially you would create a SAX event handler sitting between the parser and the Validator which would track the KeyField information as it passes the events through. This is hard to describe without a lot of handwaving and whiteboard diagrams ;) - fortunately, Elliotte Rusty Harold's chapter on the sort of thing is available online with many examples. Please let us know what you come up with! Bill