python-zeep
python-zeep copied to clipboard
Enumeration: how to get available values
Hello,
Spend a time learning from code to get the complete list of values described in enumeration but didnt find. Having this scheme:
schema = xsd.Schema(
load_xml(
"""
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://tests.python-zeep.org/"
targetNamespace="http://tests.python-zeep.org/"
elementFormDefault="qualified">
<simpleType name="CountryNameType">
<list>
<simpleType>
<restriction base="string">
<enumeration value="None"/>
<enumeration value="AlternateName"/>
<enumeration value="City"/>
<enumeration value="Code"/>
<enumeration value="Country"/>
</restriction>
</simpleType>
</list>
</simpleType>
<element name="something" type="tns:CountryNameType"/>
</schema>
"""
)
)
How do I get the list ['None', 'AlternateName', 'City', 'Code', 'Country']?
>>> element_cls = schema.get_element("{http://tests.python-zeep.org/}something")
>>> element_cls
<Element(name='something', type=<zeep.xsd.types.collection.ListType object at 0x7fb056073ac0>)>
Which is a ListType of strings with possible values that should be exposed I guess.