@@ -309,6 +309,54 @@ def test_xml_custom_uint32(self):
309309 o = self .opc .nodes .objects .add_variable (2 , "xmlcustomunit32" , 0 , varianttype = ua .VariantType .UInt32 , datatype = t .nodeid )
310310 self ._test_xml_var_type (o , "cuint32" )
311311
312+ def test_xml_var_nillable (self ):
313+ xml = """
314+ <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">
315+ <NamespaceUris>
316+ </NamespaceUris>
317+ <Aliases>
318+ <Alias Alias="Boolean">i=1</Alias>
319+ <Alias Alias="String">i=12</Alias>
320+ <Alias Alias="HasTypeDefinition">i=40</Alias>
321+ <Alias Alias="HasComponent">i=47</Alias>
322+ </Aliases>
323+ <UAVariable BrowseName="2:xmlstring" DataType="String" NodeId="ns=2;s=test_xml.string.nillabel" ParentNodeId="i=85">
324+ <DisplayName>xmlstring</DisplayName>
325+ <Description>xmlstring</Description>
326+ <References>
327+ <Reference IsForward="false" ReferenceType="HasComponent">i=85</Reference>
328+ <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
329+ </References>
330+ <Value>
331+ <uax:String></uax:String>
332+ </Value>
333+ </UAVariable>
334+
335+ <UAVariable BrowseName="2:xmlbool" DataType="Boolean" NodeId="ns=2;s=test_xml.bool.nillabel" ParentNodeId="i=85">
336+ <DisplayName>xmlbool</DisplayName>
337+ <Description>xmlbool</Description>
338+ <References>
339+ <Reference IsForward="false" ReferenceType="HasComponent">i=85</Reference>
340+ <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
341+ </References>
342+ <Value>
343+ <uax:Boolean></uax:Boolean>
344+ </Value>
345+ </UAVariable>
346+
347+ </UANodeSet>
348+ """
349+
350+ fp = open ('import-nillable.xml' , 'w' )
351+ fp .write (xml )
352+ fp .close ()
353+ # TODO: when the xml parser also support loading from string, remove write to file
354+ _new_nodes = self .opc .import_xml ('import-nillable.xml' )
355+ var_string = self .opc .get_node (ua .NodeId ('test_xml.string.nillabel' , 2 ))
356+ var_bool = self .opc .get_node (ua .NodeId ('test_xml.bool.nillabel' , 2 ))
357+ self .assertEqual (var_string .get_value (), None )
358+ self .assertEqual (var_bool .get_value (), None )
359+
312360 def _test_xml_var_type (self , node , typename , test_equality = True ):
313361 dtype = node .get_data_type ()
314362 dv = node .get_data_value ()
0 commit comments