opcua-asyncio
opcua-asyncio copied to clipboard
Export xml generates invalid xml with variables of type ExtensionObject
Using the example server-custom-structures-and-enums.py and changing the code like mynode = await server.nodes.objects.add_variable(idx, "my_struct", ua.Variant(ua.MyStruct(), ua.VariantType.ExtensionObject)) and then adding the mynode variable in the list of nodes to export to xml with:
await server.export_xml([server.nodes.objects, server.nodes.root, snode1, snode2, snode3, enode, valnode, mynode], "structs_and_enum.xml")
in the generated xml it generates wrong syntax inside the UAVariable element that describes my_struct node
<Value> <uax:ExtensionObject> <uax:TypeId> <uax:Identifier>ns=2;i=1</uax:Identifier> </uax:TypeId> <uax:Body> <uax:ns=1;i=1> <uax:MyBool>true</uax:MyBool> <uax:MyUInt32List /> </uax:ns=1;i=1> </uax:Body> </uax:ExtensionObject> </Value>
The line uax:ns=1;i=1 inside the uax:Body element is not correctly generated, a syntax checker for xml fails on it.
Python-Version: 3.9.9
opcua-asyncio Version : 0.9.94
examples.zip
The xmlexport is a bit rough. The problem is, that currently only small subset of the xml encoding is supported. To support every value a node can have, we must support the whole xml encoding.
Also I am not a fan of having variable values in the nodeset at all. I provided a patch (#923) to enable/disable export of variable values. If you don't need the values, then you can get a correct xml.
Can this issue be closed now ?