aspose file tools*
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
Author

Validating with xsd

Neil Rice
Greenhorn

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:

<Data>

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

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

</Data>

What is the most straight forward way to link the error with the <Keyfield> value as the document is being parsed?

Thanks.






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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18829
    
  40

This question probably fits best in the XML forum.

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

Henry


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

Joined: Mar 22, 2000
Posts: 12781
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating with xsd