opcua-asyncio icon indicating copy to clipboard operation
opcua-asyncio copied to clipboard

Export xml generates invalid xml with variables of type ExtensionObject

Open wvalcke opened this issue 2 years ago • 2 comments


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

wvalcke avatar Jun 09 '22 07:06 wvalcke

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.

schroeder- avatar Jun 09 '22 17:06 schroeder-

Can this issue be closed now ?

wvalcke avatar Jun 21 '22 11:06 wvalcke