I am validating xml file with xsd and i want to return meaningful messages to user. is there any way to build custom messages in xsd.
The schema is defined by the XSD. Schema errors occur where there is a problem with the structure or order of the file, or an invalid character is included. Schema errors prevent the validation being run in full because the file cannot be read. This means that errors cannot be traced to a particular record.
All you have to do is just paste the XML and click on “Check XSD validity” button. In XML Schema Definition (XSD), we can verify: Checking the schema in its value. The same name field by checking its data type.
Typically, the system returns this error if there was a problem with authentication due to an error in the submitted Merchant Id, user, and/or password. The problem may also be due to the use of single quotes around the attribute (merchantId) value. Error validating xml data against the schema on line 1.
A schema validation error is an error in the required formatting of the electronic file established by the taxing authority which can be caused by missing or invalid information.
The answers "no" and "yes" (or "yes, but ...") both apply here, depending on what you want; unfortunately, for all practical purposes the answer is "no".
The XSD spec does not specify or constrain APIs or user interfaces, so there is no standard way to specify, in an XSD schema document, what message to give the user if a particular constraint is violated. It is perfectly legitimate for schema processors to allow you some way to control the error messages, and the xs:appinfo element is included in part to make things like that feasible. But I don't know of any schema validators that actually do provide that kind of facility (I'd be glad to learn of any that do).
One possible workaround: XSD does suggest specific error codes for use by validators, so if your validator provides an API for validation results, you may be able to identify the errors raised and use the error codes and location information to generate suitable error messages for your users. The same may be true if your processor produces written output you can parse.
The simplest way to get nifty user-specifiable error messages, customizable based on just what has gone wrong, is to use Schematron, which does prescribe that processors use error messages specified by the schema author. (I expect there is some handwaving somewhere to deal with internationalization, but I don't know any details.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With