4

我正在尝试实现第 3 方服务(+1 投票支持从 WSDL 自动生成服务!)并且我正在尝试使用强制匿名选择声明一个类型。从外部 XSD 我有:

<xsd:complexType name="PriceType">
    <xsd:sequence>
        <xsd:element maxOccurs="1" minOccurs="1" name="totalAmount" type="xsd:decimal">
        </xsd:element>
        <xsd:choice maxOccurs="1" minOccurs="1">
            <xsd:element maxOccurs="1" minOccurs="0"
                         name="currencyCode" type="CurrencyCodeType">
            </xsd:element>
            <xsd:element maxOccurs="1" minOccurs="0"
                         name="currencynit" type="CurrencyUnitType">
            </xsd:element>
        </xsd:choice>
    </xsd:sequence>
</xsd:complexType>

我所拥有的是

class PriceType(ComplexModel):
    totalAmount = Decimal(min_occurs=1)
    currencyCode = CurrencyType(xml_choice_group="price_unit_choice")
    unit = CodeNameType(xml_choice_group="price_unit_choice")

但我不确定如何指定“price_unit_choice”组的强制性质。我找不到如何在 Spyne 文档和测试文件中设置选择元素的 min_occurs/max_occurs。有没有人可以分享一个例子?

4

0 回答 0