XSD 方案语法和 gSoap

XSD scheme syntax and gSoap

本文关键字:gSoap 语法 方案 XSD      更新时间:2023-10-16

我有一个问题,这个XSD语法有效吗?因为当我使用 gSOAP 时,它会向我发出警告,因为它创建了结构(C/C++ 代码(,它由另外两个具有相同名称的结构(名称 C(组成,然后当我尝试在 c/c++ 编译器中编译该代码时,它会产生错误(因为一个结构内具有相同名称的结构(。这里有如何在不接触 XSD 文件的情况下解决此问题的可能性吗?

<complexType name="A">
<choice>
<sequence>
<element name="B" type="base64Binary"/>
<element name="C" type="base64Binary" minOccurs="0"/>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<sequence>
<element name="C" type="base64Binary"/>
<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</choice>
</complexType>

在 gSOAP 中,我使用以下方法创建它:wsdl2h.exe -oSoap.h -s -y -c a.wsdl b.wsdl ...

soapcpp2.exe -C -L -n -x -w -c -d.source Soap.h

是的,它是有效的 XSD 语法;它看起来像您的代码生成器无法处理的情况。

soapcpp2 工具只抱怨,但生成的代码按设计工作。我对此进行了研究并对其进行了测试。

这是我由soapcpp2生成的:

class ns__A
{ public:
//  BEGIN CHOICE <xs:choice>
/// @note <xs:choice> with embedded <xs:sequence> or <xs:group> prevents the use of a union for <xs:choice>. Instead of being members of a union, the following members are declared optional. Only one member should be non-NULL by choice.
//  BEGIN SEQUENCE <xs:sequence>
/// Element "B" of XSD type xs:base64Binary.
    xsd__base64Binary*                   B                              nullptr;    ///< Required nillable (xsi:nil when NULL) element.
/// Element "C" of XSD type xs:base64Binary.
    xsd__base64Binary*                   C                             ;    ///< Required element.
/// Size of the array of XML or DOM nodes is 0..unbounded.
    std::vector<_XML                   > __any                         0;   ///< Catch any element content in XML string.
//  END OF SEQUENCE
//  BEGIN SEQUENCE <xs:sequence>
/// Element "C" of XSD type xs:base64Binary.
    xsd__base64Binary*                   C                              nullptr;    ///< Required nillable (xsi:nil when NULL) element.
/// Size of the array of XML or DOM nodes is 0..unbounded.
    std::vector<_XML                   > __any                         0;   ///< Catch any element content in XML string.
//  END OF SEQUENCE
//  END OF CHOICE
/// A handle to the soap struct context that manages this instance when instantiated by a context or NULL otherwise (automatically set).
    struct soap                         *soap                          ;
};

soapcpp2 报告的"问题"的原因是流式序列化程序无法区分C的选择。所以两者都是编码的。第二个C重命名为 C_,并且从不用于反序列化数据。

简单的解释:你很好。