• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extracting path of the element during xsd validation

 
Ranch Hand
Posts: 188
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic