0

I'm facing the following problem concerning xml validation with gSOAP:

I use wsdl2h to generate a header file from my xsd and soapcpp2 to generate C sources from that header file. Using the generated sources in my program I'm able to write an xml file.

Is there any way to validate the generated xml file against the xsd after/during generation?

Thanks, Flo

1 Answers1

0

The generated XML structure will be valid according to the XSD by gsoap tooling design (data binding and serialization), but there are some cases where you will have to heed specific XSD requirements on element and attribute occurrence constraints. These are included in the generated .h file and associated with struct/class members as range information min:max. So, in that case, look for the documented occurrence constraints (minOccurs, maxOccurs, etc) in the wsdl2h-generated .h file to determine how to populate C/C++ data for XML serialization. Almost everything else is automated by the type mapping algorithm.

Dr. Alex RE
  • 1,772
  • 1
  • 15
  • 23
  • The .h file generated from my .xsd contains constraint annotations such as described in [gSOAP User Guide : Chap. 17 XML Validation](http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc17). Using soapcpp2 with flags -s and -c and `soap_set_imode(&soap, SOAP_XML_STRICT);' in my code I am still able to generate an xml file that does not fit the .xsd (for example by intentionally violating occurance constraints) without getting any SOAP error. Shouldn't there appear one of the error codes mentioned in [Chap. 10.2 Error Codes](http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc10.2)? – stackoverflo Nov 18 '13 at 10:14