Commit 6db39b1a authored by oroulet's avatar oroulet

Harold Howe: XML exporter handle nodes with a null description

parent 0425f17f
......@@ -185,7 +185,9 @@ class XmlExporter:
nodeid = node.nodeid
parent = await node.get_parent()
displayname = (await node.get_display_name()).Text
desc = (await node.get_description()).Text
desc = await node.get_description()
if desc:
desc = desc.Text
node_el = Et.SubElement(self.etree.getroot(), nodetype)
node_el.attrib["NodeId"] = self._node_to_string(nodeid)
node_el.attrib["BrowseName"] = self._bname_to_string(browsename)
......@@ -413,7 +415,7 @@ class XmlExporter:
def _get_member_order(self, dtype, val):
"""
If an dtype has an entry in XmlExporter.extobj_ordered_elements return the export order of the elements
If an dtype has an entry in XmlExporter.extobj_ordered_elements return the export order of the elements
else return the unordered members.
"""
if dtype not in XmlExporter.extobj_ordered_elements.keys():
......
......@@ -191,6 +191,13 @@ async def test_xml_string(opc, tmpdir):
await _test_xml_var_type(opc, tmpdir, o, "string")
async def test_xml_string_with_null_description(opc, tmpdir):
o = await opc.opc.nodes.objects.add_variable(2, "xmlstring", "mystring")
await o.set_attribute(ua.AttributeIds.Description, ua.DataValue(None))
o2 = await _test_xml_var_type(opc, tmpdir, o, "string")
assert await o.get_description() == await o2.get_description()
async def test_xml_string_array(opc, tmpdir):
o = await opc.opc.nodes.objects.add_variable(2, "xmlstringarray", ["mystring2", "mystring3"])
node2 = await _test_xml_var_type(opc, tmpdir, o, "stringarray")
......@@ -324,7 +331,7 @@ async def test_xml_custom_uint32(opc, tmpdir):
async def test_xml_var_nillable(opc):
xml = """
<UANodeSet xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamespaceUris>
<NamespaceUris>
</NamespaceUris>
<Aliases>
<Alias Alias="Boolean">i=1</Alias>
......@@ -341,9 +348,9 @@ async def test_xml_var_nillable(opc):
</References>
<Value>
<uax:String></uax:String>
</Value>
</Value>
</UAVariable>
<UAVariable BrowseName="2:xmlbool" DataType="Boolean" NodeId="ns=2;s=test_xml.bool.nillabel" ParentNodeId="i=85">
<DisplayName>xmlbool</DisplayName>
<Description>xmlbool</Description>
......@@ -354,8 +361,8 @@ async def test_xml_var_nillable(opc):
<Value>
<uax:Boolean></uax:Boolean>
</Value>
</UAVariable>
</UAVariable>
</UANodeSet>
"""
_new_nodes = await opc.opc.import_xml(xmlstring=xml)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment