0
我還沒有找到一種方法來描述可重複基元類型的xml屬性;到目前爲止我最好的猜測:無界基元類型的XmlAttribute
class Contact(ComplexModel):
"contact person and communication channel"
contactName = primitive.Unicode(min_len=1, max_len=70, nillable=False)
channel = primitive.Unicode(max_occurs='unbounded')
channelCode = XmlAttribute(Enum('TELEPHONE', 'TELEFAX', 'EMAIL', 'WEBSITE', type_name='channelCode'), attribute_of='channel')
這將產生一個WSDL,看起來像正確的(至少對我來說):
<xs:complexType name="Contact">
<xs:sequence>
<xs:element name="channel" minOccurs="0" maxOccurs="unbounded" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="channelCode" type="tns:channelCode"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="contactName" type="tns:Contact_contactNameType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
但我不知道如何使用Contact類!
>>> c = Contact()
>>> c.contactName = 'xxx'
>>> c.channel = [ '1', '2' ]
>>> # c.channelCode = ???
它的工作原理,謝謝! – dvd