我使用this XML schema definition生成了一个模块:
$ pyxbgen -u "https://cwmp-data-models.broadband-forum.org/cwmp-1-2.xsd" -m cwmp
[Warnings about duplicate SOAP encoding/envelope complex types omitted]
Python for urn:dslforum-org:cwmp-1-2 requires 3 modules
..并且我具有以下与架构匹配的有效 XML 文档:
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cwmp="urn:dslforum-org:cwmp-1-2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">Testing123</cwmp:ID>
<cwmp:HoldRequests SOAP-ENV:mustUnderstand="1">1</cwmp:HoldRequests>
</SOAP-ENV:Header>
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<cwmp:GetParameterNames>
<ParameterPath>InternetGatewayDevice.</ParameterPath>
<NextLevel>1</NextLevel>
</cwmp:GetParameterNames>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
使用模块时,我可以看到Header
和Body
元素很好,但是所有其他元素都以自动生成的类型名结尾,并且只能通过{{1}访问}:
wildcardElements
这是怎么回事?
XSD损坏了吗?我是否误解了如何使用 PyXB ?
我的最终目标是能够按标签/名称/类型访问这些元素。有什么办法可以做到这一点?