python-zeep
python-zeep copied to clipboard
Parsing: xsd:sequence of xsd:any
Definition from one of the Oracle systems:
<xsd:complexType name="AgileObjectType">
<xsd:sequence>
<xsd:element name="objectIdentifier" type="common:ObjectIdentifierType" minOccurs="1" maxOccurs="1" nillable="true"/>
<xsd:any minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="table" type="AgileTableType" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
Recived response:
<agileObject>
<objectIdentifier> ... </objectIdentifier>
<scheduleStartDate xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:date" attributeId="18010" readOnly="True">2022-04-18T08:00:00.000Z</scheduleStartDate>
<scheduleEndDate xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:date" attributeId="18012" readOnly="True">2026-11-20T17:00:00.000Z</scheduleEndDate>
<scheduleDuration xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:double" attributeId="18011" readOnly="True">1200.0</scheduleDuration>
<estimatedStartVarianceWorkDays xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:double" attributeId="2000007677" readOnly="True">0.0</estimatedStartVarianceWorkDays>
...
<table> ... </table>
</agileObject>
Is parsed to:
'agileObject': {
'objectIdentifier': { ... },
'_value_1': [ datetime.date(2022, 4, 18), datetime.date(2026, 11, 20), 1200.0, 0.0, ... ]
The field _value_1 is just an arbitrary list of values (as the values being empty are skipped), and there's no way to understand the information.
I need to patch the function zeep/xsd/elements/any.py: parse_xmlelements:
- result = []
+ result = {}
- result.append(item)
+ result[xlmelement.tag] = item
To achive the informative version of the parsed object:
'agileObject': {
'objectIdentifier': { ... },
'_value_1': {
'scheduleStartDate': datetime.date(2022, 4, 18),
'scheduleEndDate': datetime.date(2026, 11, 20),
'scheduleDuration': 1200.0,
'estimatedStartVarianceWorkDays': 0.0,
Is that patching the only way to achieve that?