如何使用gSOAP来验证xml对xsd的影响

时间:2021-12-09 17:15:32

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

关于使用gSOAP进行xml验证,我遇到了以下问题:

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.

我使用wsdl2h从我的xsd和soapcpp2生成头文件,以从该头文件生成C源。使用我程序中生成的源代码,我可以编写一个xml文件。

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

有没有办法在生成之后/期间针对xsd验证生成的xml文件?

Thanks, Flo

1 个解决方案

#1


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.

生成的XML结构将通过gsoap工具设计(数据绑定和序列化)根据XSD有效,但在某些情况下,您必须注意元素和属性出现约束的特定XSD要求。这些包含在生成的.h文件中,并与struct / class成员关联,作为范围信息min:max。因此,在这种情况下,请在wsdl2h生成的.h文件中查找记录的事件约束(minOccurs,maxOccurs等),以确定如何为XML序列化填充C / C ++数据。几乎所有其他东西都是通过类型映射算法自动完成的。

#1


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.

生成的XML结构将通过gsoap工具设计(数据绑定和序列化)根据XSD有效,但在某些情况下,您必须注意元素和属性出现约束的特定XSD要求。这些包含在生成的.h文件中,并与struct / class成员关联,作为范围信息min:max。因此,在这种情况下,请在wsdl2h生成的.h文件中查找记录的事件约束(minOccurs,maxOccurs等),以确定如何为XML序列化填充C / C ++数据。几乎所有其他东西都是通过类型映射算法自动完成的。