• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validating with xsd

 
Neil Rice
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21003
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question probably fits best in the XML forum.

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

Henry
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic