Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get specific error message in xml validation with xsd

 
shiva kumar g
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using XSD schema to validate the XML String. I am able to validate the XML against XSD schema, but while validating the XML i am getting the SAXException messages as below

cvc-maxExclusive-valid: Value '23123132321323123123213' is not facet-valid with respect to maxExclusive '999999999999999' for type 'MerchantTrackIdType'.
cvc-type.3.1.3: The value '23123132321323123123213' of element 'MerchantTrackId' is not valid.

Here i am implementing the ErrorHandler(MyErrorHandler) class and getting the above exception messages. But to give exact error response to out i wish to get the only
The value '23123132321323123123213' of element 'MerchantTrackId' is not valid.



I googled out for getting the only cvc-type message from SAXException, Please help me in this regards if you found any solution.

Thanks in advance.
 
shiva kumar g
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Anyone please help me for the above issue. I am still working/searching on the same but no use. Any solutions for the same is greatly appreciated.

Thanks.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bare minimal to establish the "localized message" from within the ErrorHandler can be this (or some variants you can think of).

You can conceive a scheme to collect and to store the messages from within the handler and construct a method (called getLocalizedMessage() or whatever) to return the complete messages to the caller. It is up to you to do.
 
shiva kumar g
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi g tsuji,

Thanks for your reply. I will try to get resolve my issue.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic