How to handle validation of a document

X-Application Version: 4.1.1
Tamino Version : 4.1.4.1
Platform : WinXP
WebContainer : Tomcat 4.1.24
JDK Version : 1.4.1

In our schema we have defined various restrictions - e.g. patterns and enumerations. We also want to use the Tamino Unique constraints extension. Tamino sends back a fairly cryptic message if one of the rules are broken, and this lands up on an error page in XApplication. We would want to show the user the error on the data entry page, and allow him to correct it before hitting the Commit to try again. There are no examples of validation that I have found in the Property Tutorial - in fact you can enter ‘abcd’ in the number of bedrooms, which is accepted! The only reference I can find to validation in the documentation points me to the plug-ins. Is this the way validation was intended to be done? Is there any point in having restrictions in the schema if we have to do the validation in a program anyway?

Hello,

The validation of elements / attributes is currently not supported by X-Application framework. If you set the value of an element, it is not checked against the type definition of this element by the X-Application framework.

What you can do to add validation functionality is a plug-in. You could plug-in your validation code when a document is committed. You would write a document action.

Within this plug-in:

If you want to validate the document against a schema, the workspace object gives you access to the currently loaded schemas.

If you don’t want to validate the document on application side,
- Sent the document to Tamino,
- Catch the exception if the document is invalid,
- Transform the exception to your exception containing information for the user,
- Represent the exception within an error page that explains the errors of the user input.

You will find a description how to write a plug-in within X-Application’s documentation. If you have problems don’t hesitate to post your code to the community and to ask for support.

Bye,
Christian.

Thanks Christian,
Is there any documentation on how to access the schema in the workspace? Or an example somewhere? There must be coding somewhere which picks up the defaults and enumerations from the schema to create a new document - is the source of this available?

Priscilla

Hello,

Have a look into the java doc of X-Application:

The class BusinessDocumentWorkspace holds a schema set. This set contains the schemas you defined within your X-Application configuration file.

The object SchemaSet is a collection of Schema objects. The object Schema has the method

toString</pre> returning the string representation of the schema. <BR><BR>However, we are using the eclipse schema model for the internal representation of schema. If you want to use it for your validation, you can use the method <pre class="ip-ubbcode-code-pre">getXSDSchema</pre> to get access to this representation.<BR><BR>95% of the schema handling for X-Application are implemented by classes of the package<BR><BR><pre class="ip-ubbcode-code-pre">
com.softwareag.xtools.xapplication.schema



Here you will find the class Schema. For the other classes of this package I think that they are rather uninteresting for your purpose.

What is your plan for validating a document?

Do you want validate the document before sending it to Tamino?

Bye,
Christian.

Thanks for pointing me in the right direction, Christian. My idea is to validate the document before it gets sent to Tamino so we can give the user a meaningful message. Maybe I will use the schema to do this. I now have lots of documentation to study!
Thanks
Priscilla