我正在尝试将一个名为 nbReports 的内部 nillable 元素设置为 null,但到目前为止我失败了。
XSD 文件的快照和代码如下:
<xs:element name="reports" type="tns:Reports"/>
<xs:complexType name="Reports">
<xs:sequence>
<xs:element minOccurs="0" name="description" type="xs:string"/>
<xs:element minOccurs="0" name="reportingGroups">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0"
name="reportingGroup" type="tns:ReportingGroupType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ReportingGroupType">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="nbReports" type="xs:int" nillable="true"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
代码快照:
import reports
rep=reports.reports()
rep.description="this report is ..."
temp=ReportingGroupType(id=xs.string("A1")
temp.title="this title")
temp.nbReports._setIsNil #"error: AttributeError: 'NoneType' object has no attribute '_setIsNil'
如果我尝试将 nbReports 设置为任何值(例如 4)以创建 nbReprots 的实例,然后将其设置为 null,那么当我打印它时,nbReprots 的值将保持为 4。