File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Validating with xsd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Validating with xsd" Watch "Validating with xsd" New topic

Validating with xsd

Neil Rice

Joined: Aug 19, 2002
Posts: 1
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:


<Information>info about key field 1</Information>

<Information>info about key field 2</Information>


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?
Henry Wong

Joined: Sep 28, 2004
Posts: 20517

This question probably fits best in the XML forum.

Moving this to the "XML and related technologies" forum.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
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!
I agree. Here's the link:
subject: Validating with xsd
It's not a secret anymore!