mirror of
https://github.com/open62541/open62541.git
synced 2025-06-03 04:00:21 +00:00
fix(nodeset-compiler): Use ParentNodeId attribute for parent node where possible
This commit is contained in:
parent
0a6ccdbe44
commit
f1f35981ea
@ -74,6 +74,7 @@ class Node(object):
|
||||
self.modelUri = None
|
||||
self.parent = None
|
||||
self.parentReference = None
|
||||
self.parentIdAttribute = None
|
||||
|
||||
def __str__(self):
|
||||
return self.__class__.__name__ + "(" + str(self.id) + ")"
|
||||
@ -104,6 +105,8 @@ class Node(object):
|
||||
self.eventNotifier = int(av)
|
||||
elif at == "SymbolicName":
|
||||
self.symbolicName = String(av)
|
||||
elif at == "ParentNodeId":
|
||||
self.parentIdAttribute = NodeId(av)
|
||||
|
||||
for x in xmlelement.childNodes:
|
||||
if x.nodeType != x.ELEMENT_NODE:
|
||||
@ -177,6 +180,8 @@ class Node(object):
|
||||
self.browseName.ns = nsMapping[self.browseName.ns]
|
||||
if hasattr(self, 'dataType') and isinstance(self.dataType, NodeId):
|
||||
self.dataType.ns = nsMapping[self.dataType.ns]
|
||||
if self.parentIdAttribute is not None:
|
||||
self.parentIdAttribute.ns = nsMapping[self.parentIdAttribute.ns]
|
||||
new_refs = set()
|
||||
for ref in self.references:
|
||||
ref.source.ns = nsMapping[ref.source.ns]
|
||||
|
@ -388,6 +388,17 @@ class NodeSet(object):
|
||||
# ModellingRule, Root node do not have a parent
|
||||
continue
|
||||
|
||||
# Check if the Nodeset explicitly defines a parent node
|
||||
if node.parentIdAttribute is not None:
|
||||
for ref in node.references:
|
||||
if ref.target == node.parentIdAttribute:
|
||||
node.parent = self.nodes[node.parentIdAttribute]
|
||||
node.parentReference = self.nodes[ref.referenceType]
|
||||
break
|
||||
if node.parent is not None:
|
||||
# if found, then stop here. Otherwise try to automatically determine parent based on refs
|
||||
continue
|
||||
|
||||
parentref = node.getParentReference(parentreftypes)
|
||||
if parentref is not None:
|
||||
node.parent = self.nodes[parentref.target]
|
||||
|
Loading…
Reference in New Issue
Block a user