Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extracting path of the element during xsd validation

 
Sudarshan Sreenivasan
Ranch Hand
Posts: 188
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using a errorHandler to handle the errors which occur during parsing.

Further i use XSD validation.

The requirement is to find the entire path of the element at which the xsd validation has failed.

At present the parser gives an error like
Invalid text '' in element: 'date_of_birth'


However if the date_of_birth element was found under two parents the end user would get confused.

Therefore i need a way to specify under which element does the date_of_birth tag come under.

Example client/date_of_birth or beneficiary/date_of_birth.

Thanks
Sudarshan
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't say what kind of exception this is. If it is a SAXParseException then you have getColumnNumber() and getLineNumber() methods.

You might also give the users some tool which helps them to create valid documents, instead of making them do the enter, run, fix errors cycle.
 
Sudarshan Sreenivasan
Ranch Hand
Posts: 188
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Yes i am catching the saxEcxception did run through the methods you mentioned but this is not of much use to our end client.

Actually the requirement is such that the client creates an xml through a set of forms.

We recieve this xml through a web service, process it & send back a response xml.

The response xml could specify the errors found in the request xml/subsequent business processing. Which the client software will reverse map to the fields in the form.

Now this requires us to able to uniquely identify a tag in case of a failure during the xsd validation.

I was thinking the XPath of the element would help us achieve this however cant find a way to extract the xpath of an element which has failed in the xsd validation process.

I believe that if each element had a id attribute which can help uniquely identify it then that would also serve the purpose.

But again how do i get hold of the id attribute of the element which has cause the xsd validation to fail.

Would like to add that i am using oracle's xmlparserv2 to perform the parsing and validations.


Thanks
Sudarshan
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, basically the purpose of validation is to determine whether the document is valid. That's all. It isn't like a compiler which tries to identify all errors, it just says "yes" or "no" to the question of whether the document is valid.

As I said, if your users are having problems creating valid documents, it would be better to provide them with tools that make it easier for them.
 
Sudarshan Sreenivasan
Ranch Hand
Posts: 188
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i cant do that at present.
The validator does tell which element has caused the validation to fail.
So i was guessing we could get a few more details out of it ?

Thanks
Sudarshan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic