Generated Validation Functions
The -valid or -genvalid option causes validation functions to be generated. These functions can be used to validate a given XML instance against the compiled schema type. They are similar to decode functions in that either the pull-parser or generated SAX handlers are used to parse an XML instance. The handlers in this case do not fully decode the instance; instead, they just check that the instance satisifies all of the constraints specified in the schema.
where <xsdFileName> is the base name of the XSD file being parsed. For example, if code is being generated for file x.xsd and -valid is specified, validation functions will be written to xVldt.c. If the file being processed is a WSDL file, the suffix would be WSDLVldt.c (for example, x.wsdl would produce xWSDLVldt.c).
where <elemName> is the name of the XSD global element for which the function is being generated and <ns> is an optional namespace setting that can be used to disambiguate names from multiple sources (note: this should not be confused with XML namespaces which are different). Note that validation functions are only generated for global elements, not types.
OSBOOL result = <validationFunc> (OSCTXT* pctxt);The pctxt argument is used to hold a context pointer to keep track of dynamic memory allocation parameters. This is a basic "handle" variable that is used to make the function reentrant so that it can be used in an asynchronous or threaded application. The user is required to supply a pointer to a variable of this type declared somewhere in his or her program. The variable must be initialized using either the rtxInitContext or rtXmlInitContext run-time function before use.
The result function return code is a boolean variable indicating whether the message is valid or not. If the message is not valid, reasons for failure will be stored on the error list within the context. The rtxErr functions can be used to examine this list (see the XBinder C/C++ Run-time Reference Manual for details). The simplest way to access this information is to call rtxErrPrint which will print details on all errors to stderr.
Copyright © Objective Systems 2002-2008 This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included. |
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |