Improve XML NodeSet merge tool script
S2OPC contains some basic scripts to facilitate standard XML files (see ./schemas/UANodeSet.xsd
).
For example, the script nodeset-address-space-utils.py
allows the merge operation of two dataset files.
However, some improvement shall be added to this script:
- managing the namespace translation of NodeIds in case of merge. Each namespace index is associated to a namespace uri. NamespaceURIs are declared at the begining of each file to merge. If two NamespaceURI are declared at the same index, the second one needs to take another index and the associated nodesIds of the file need to be translated. The user needs to be able to define which NamespaceURIs corresponds to the index 1. Merger the aliases. Erreur in case of conflit.
- generate the NamespaceURIs in specific nodes NamespaceArray (array of string) and ServerArray
- fix the fact that the result of the merge operation is different given the order of XML input parameters (deterministic output)
- add the capacity to remove a node and all its children (if they don't have any other parent)
- add the capacity to remove from a model all the type definitions which are not used by a model (except basic/standard datatypes which are mandatory). Follow references such as HasType. In case of inheritance, if a child type is kept, all parents type need to be kept as well.
Edit:
During the implementation and review phases, new desired features appeared (below in comments):
- Merge script: add the possibility two models in a single namespace, according to the namespace URIs declared in every file
- Option
--remove-unused
to remove unused type, with a sub-option--retain-ns0
to keep NS0 nodes. Default option is to exclude NS0. Add another sub-option--retain-types
to list some specific nodes as exception ("ns=x,i=xxx ns=y,i=yyy..."). - Add an option
--remove-backward-refs
to remove backward references, so as to reduce the size of the merged files. A backward reference is a reference with attributeIsForward="false"
. - Add a sub-option
--remove-backward-refs-retain
to provide a list of reference types for which the backward references shall be retained. The reference types may be designated by either a NodeId or an Alias. - Add an option
--remove-orphans
to remove the objects and variables with no hierarchical parent. - Assimilate HasEncoding as a hierarchical reference: existence of target node of an HasEncoding directly depends on source node
Edited by Vincent Monfort