Menu

#274 wsdl2py does not handle <choice> schema element correctly

v2.1
open
nobody
zsi (169)
5
2009-05-20
2009-05-20
vpod
No

wsdl2py code generator does not produce correct code for xml schema <choice> element. For example:

<xs:complexType name="PaginationType">
<xs:choice>
<xs:sequence>
<xs:element ref="tns:StartPage"/>
<xs:element ref="tns:EndPage" minOccurs="0"/>
<xs:element ref="tns:MedlinePgn" minOccurs="0"/>
</xs:sequence>
<xs:element ref="tns:MedlinePgn"/>
</xs:choice>
</xs:complexType>

This XML fragment results in the following code for inner Holder class:

class Holder:
typecode = self
def __init__(self):
# pyclass
self._StartPage = None
self._EndPage = None
self._MedlinePgn = None
self._MedlinePgn = None
return

"MedlinePgn" element also appears twice in TClist, which leads to a
"previously defined attribute" error when trying to import generated code.

The "-b" switch was used for wsdl2py. Without it, getters and setters are not constructed and
the error is hidden from the user (generated code can be imported, but is technically not correct ).

ZSI used: latest (1492) svn snapshot
WSDL: PubMed: http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_pubmed.wsdl

Regards,
Vid

Discussion


Log in to post a comment.