XSD 方案语法和 gSoap
XSD scheme syntax and gSoap
我有一个问题,这个 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 报告 "issue" 的原因是流序列化器无法区分 C
的选择。所以两者都是编码的。第二个 C
被重命名为 C_
并且从不用于反序列化数据。
简单解释:你很好。
我有一个问题,这个 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 报告 "issue" 的原因是流序列化器无法区分 C
的选择。所以两者都是编码的。第二个 C
被重命名为 C_
并且从不用于反序列化数据。
简单解释:你很好。