FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.36k stars 660 forks source link

[Server] Import XML - Dependency Order #258

Closed maljac closed 8 years ago

maljac commented 8 years ago

Hi,

the current implementation of the XML Importer / Parser does not take into account the dependencies of the nodes defined in the xml. Currently it tries to create nodes according to the order of the XML elements.

Workaround: Import the files a second time.

Feature proposal: Respect the dependency tree defined in the XML nodes while importing.

oroulet commented 8 years ago

I did not even know there was such a thing. How do you read the dependencies?

On Fri, Jul 29, 2016, 11:27 maljac notifications@github.com wrote:

Hi,

the current implementation of the XML Importer / Parser does not take into account the dependencies of the nodes defined in the xml. Currently it tries to create nodes according to the order of the XML elements.

Workaround: Import the files a second time.

Feature proposal: Respect the dependency tree defined in the XML nodes while importing.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FreeOpcUa/python-opcua/issues/258, or mute the thread https://github.com/notifications/unsubscribe-auth/ACcfzm_Vunw6PcGSRhFhgEpy7hxErJsMks5qacdwgaJpZM4JYBgF .

zerox1212 commented 8 years ago

Can you post an example XML that would cause this?

maljac commented 8 years ago

Example:

<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:s1="http://myorg.de/simpleModel/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <NamespaceUris>
        <Uri>http://myorg.de/simpleModel/</Uri>
    </NamespaceUris>
    <Aliases>
        <Alias Alias="Double">i=11</Alias>
        <Alias Alias="String">i=12</Alias>
        <Alias Alias="ByteString">i=15</Alias>
        <Alias Alias="LocalizedText">i=21</Alias>
        <Alias Alias="HasModellingRule">i=37</Alias>
        <Alias Alias="HasEncoding">i=38</Alias>
        <Alias Alias="HasDescription">i=39</Alias>
        <Alias Alias="HasTypeDefinition">i=40</Alias>
        <Alias Alias="GeneratesEvent">i=41</Alias>
        <Alias Alias="HasSubtype">i=45</Alias>
        <Alias Alias="HasProperty">i=46</Alias>
        <Alias Alias="HasComponent">i=47</Alias>
        <Alias Alias="MachineStateEnum">ns=1;i=3002</Alias>
        <Alias Alias="SpindleStatus">ns=1;i=3003</Alias>
        <Alias Alias="AxesPosition">ns=1;i=3004</Alias>
    </Aliases>
    <Extensions>
        <Extension>
            <ModelInfo Tool="UaModeler" Hash="c8VvmA89MWQ5CRq41HZn3w==" Version="1.4.4"/>
        </Extension>
    </Extensions>
    <UADataType NodeId="ns=1;i=3002" BrowseName="1:MachineStateEnum">
        <DisplayName>MachineStateEnum</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty">ns=1;i=6003</Reference>
            <Reference ReferenceType="HasSubtype" IsForward="false">i=29</Reference>
        </References>
        <Definition Name="1:MachineStateEnum">
            <Field Name="STOPPED" Value="0"/>
            <Field Name="RUNNING" Value="1"/>
        </Definition>
    </UADataType>
    <UAVariable DataType="LocalizedText" ParentNodeId="ns=1;i=3002" ValueRank="1" NodeId="ns=1;i=6003" ArrayDimensions="2" BrowseName="EnumStrings">
        <DisplayName>EnumStrings</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=3002</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
        <Value>
            <uax:ListOfLocalizedText>
                <uax:LocalizedText>
                    <uax:Text>STOPPED</uax:Text>
                </uax:LocalizedText>
                <uax:LocalizedText>
                    <uax:Text>RUNNING</uax:Text>
                </uax:LocalizedText>
            </uax:ListOfLocalizedText>
        </Value>
    </UAVariable>
    <UADataType NodeId="ns=1;i=3003" BrowseName="1:SpindleStatus">
        <DisplayName>SpindleStatus</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty">ns=1;i=6004</Reference>
            <Reference ReferenceType="HasSubtype" IsForward="false">i=29</Reference>
        </References>
        <Definition Name="1:SpindleStatus">
            <Field Name="STOPPED" Value="0"/>
            <Field Name="RUNNING" Value="1"/>
        </Definition>
    </UADataType>
    <UAVariable DataType="LocalizedText" ParentNodeId="ns=1;i=3003" ValueRank="1" NodeId="ns=1;i=6004" ArrayDimensions="2" BrowseName="EnumStrings">
        <DisplayName>EnumStrings</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=3003</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
        <Value>
            <uax:ListOfLocalizedText>
                <uax:LocalizedText>
                    <uax:Text>STOPPED</uax:Text>
                </uax:LocalizedText>
                <uax:LocalizedText>
                    <uax:Text>RUNNING</uax:Text>
                </uax:LocalizedText>
            </uax:ListOfLocalizedText>
        </Value>
    </UAVariable>
    <UADataType NodeId="ns=1;i=3004" BrowseName="1:AxesPosition">
        <DisplayName>AxesPosition</DisplayName>
        <References>
            <Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
            <Reference ReferenceType="HasEncoding">ns=1;i=5001</Reference>
            <Reference ReferenceType="HasEncoding">ns=1;i=5002</Reference>
        </References>
        <Definition Name="1:AxesPosition">
            <Field DataType="Double" Name="X1"/>
            <Field DataType="Double" Name="Y1"/>
            <Field DataType="Double" Name="Z1"/>
        </Definition>
    </UADataType>
    <UAVariable DataType="String" Historizing="true" ParentNodeId="ns=1;i=6006" NodeId="ns=1;i=6010" BrowseName="1:AxesPosition">
        <DisplayName>AxesPosition</DisplayName>
        <References>
            <Reference ReferenceType="HasDescription" IsForward="false">ns=1;i=5001</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=6006</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=69</Reference>
        </References>
        <Value>
            <uax:String>AxesPosition</uax:String>
        </Value>
    </UAVariable>
    <UAVariable DataType="String" Historizing="true" ParentNodeId="ns=1;i=6008" NodeId="ns=1;i=6011" BrowseName="1:AxesPosition">
        <DisplayName>AxesPosition</DisplayName>
        <References>
            <Reference ReferenceType="HasDescription" IsForward="false">ns=1;i=5002</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=6008</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=69</Reference>
        </References>
        <Value>
            <uax:String>//xs:element[@name='AxesPosition']</uax:String>
        </Value>
    </UAVariable>
    <UAVariable DataType="ByteString" NodeId="ns=1;i=6006" BrowseName="1:TypeDictionary">
        <DisplayName>TypeDictionary</DisplayName>
        <Description>Collects the data type descriptions of http://yourorganisation.org/simpleModel/</Description>
        <References>
            <Reference ReferenceType="HasComponent">ns=1;i=6010</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=72</Reference>
            <Reference ReferenceType="HasProperty">ns=1;i=6007</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">i=93</Reference>
        </References>
        <Value>
            <uax:ByteString>PG9wYzpUeXBlRGljdGlvbmFyeSB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZ
        W1hLWluc3RhbmNlIiB4bWxuczp0bnM9Imh0dHA6Ly9teW9yZy5kZS9zaW1wbGVNb2RlbC8iI
        ERlZmF1bHRCeXRlT3JkZXI9IkxpdHRsZUVuZGlhbiIgeG1sbnM6b3BjPSJodHRwOi8vb3BjZ
        m91bmRhdGlvbi5vcmcvQmluYXJ5U2NoZW1hLyIgeG1sbnM6dWE9Imh0dHA6Ly9vcGNmb3VuZ
        GF0aW9uLm9yZy9VQS8iIFRhcmdldE5hbWVzcGFjZT0iaHR0cDovL215b3JnLmRlL3NpbXBsZ
        U1vZGVsLyI+CiA8b3BjOkltcG9ydCBOYW1lc3BhY2U9Imh0dHA6Ly9vcGNmb3VuZGF0aW9uL
        m9yZy9VQS8iLz4KIDxvcGM6U3RydWN0dXJlZFR5cGUgQmFzZVR5cGU9InVhOkV4dGVuc2lvb
        k9iamVjdCIgTmFtZT0iQXhlc1Bvc2l0aW9uIj4KICA8b3BjOkZpZWxkIFR5cGVOYW1lPSJvc
        GM6RG91YmxlIiBOYW1lPSJYMSIvPgogIDxvcGM6RmllbGQgVHlwZU5hbWU9Im9wYzpEb3Vib
        GUiIE5hbWU9IlkxIi8+CiAgPG9wYzpGaWVsZCBUeXBlTmFtZT0ib3BjOkRvdWJsZSIgTmFtZ
        T0iWjEiLz4KIDwvb3BjOlN0cnVjdHVyZWRUeXBlPgogPG9wYzpFbnVtZXJhdGVkVHlwZSBMZ
        W5ndGhJbkJpdHM9IjMyIiBOYW1lPSJNYWNoaW5lU3RhdGVFbnVtIj4KICA8b3BjOkVudW1lc
        mF0ZWRWYWx1ZSBOYW1lPSJTVE9QUEVEIiBWYWx1ZT0iMCIvPgogIDxvcGM6RW51bWVyYXRlZ
        FZhbHVlIE5hbWU9IlJVTk5JTkciIFZhbHVlPSIxIi8+CiA8L29wYzpFbnVtZXJhdGVkVHlwZ
        T4KIDxvcGM6RW51bWVyYXRlZFR5cGUgTGVuZ3RoSW5CaXRzPSIzMiIgTmFtZT0iU3BpbmRsZ
        VN0YXR1cyI+CiAgPG9wYzpFbnVtZXJhdGVkVmFsdWUgTmFtZT0iU1RPUFBFRCIgVmFsdWU9I
        jAiLz4KICA8b3BjOkVudW1lcmF0ZWRWYWx1ZSBOYW1lPSJSVU5OSU5HIiBWYWx1ZT0iMSIvP
        gogPC9vcGM6RW51bWVyYXRlZFR5cGU+Cjwvb3BjOlR5cGVEaWN0aW9uYXJ5Pgo=</uax:ByteString>
        </Value>
    </UAVariable>
    <UAVariable DataType="String" Historizing="true" ParentNodeId="ns=1;i=6006" NodeId="ns=1;i=6007" BrowseName="NamespaceUri">
        <DisplayName>NamespaceUri</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=6006</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
        <Value>
            <uax:String>http://myorg.de/simpleModel/</uax:String>
        </Value>
    </UAVariable>
    <UAVariable DataType="ByteString" NodeId="ns=1;i=6008" BrowseName="1:TypeDictionary">
        <DisplayName>TypeDictionary</DisplayName>
        <Description>Collects the data type descriptions of http://yourorganisation.org/simpleModel/</Description>
        <References>
            <Reference ReferenceType="HasComponent">ns=1;i=6011</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=72</Reference>
            <Reference ReferenceType="HasProperty">ns=1;i=6009</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">i=92</Reference>
        </References>
        <Value>
            <uax:ByteString>PHhzOnNjaGVtYSBlbGVtZW50Rm9ybURlZmF1bHQ9InF1YWxpZmllZCIgdGFyZ2V0TmFtZXNwYWNlPSJod
        HRwOi8vbXlvcmcuZGUvc2ltcGxlTW9kZWwvVHlwZXMueHNkIiB4bWxuczp0bnM9Imh0dHA6L
        y9teW9yZy5kZS9zaW1wbGVNb2RlbC9UeXBlcy54c2QiIHhtbG5zOnVhPSJodHRwOi8vb3BjZ
        m91bmRhdGlvbi5vcmcvVUEvMjAwOC8wMi9UeXBlcy54c2QiIHhtbG5zOnhzPSJodHRwOi8vd
        3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYSI+CiA8eHM6aW1wb3J0IG5hbWVzcGFjZT0iaHR0c
        DovL29wY2ZvdW5kYXRpb24ub3JnL1VBLzIwMDgvMDIvVHlwZXMueHNkIi8+CiA8eHM6c2ltc
        GxlVHlwZSBuYW1lPSJNYWNoaW5lU3RhdGVFbnVtIj4KICA8eHM6cmVzdHJpY3Rpb24gYmFzZ
        T0ieHM6c3RyaW5nIj4KICAgPHhzOmVudW1lcmF0aW9uIHZhbHVlPSJTVE9QUEVEXzAiLz4KI
        CAgPHhzOmVudW1lcmF0aW9uIHZhbHVlPSJSVU5OSU5HXzEiLz4KICA8L3hzOnJlc3RyaWN0a
        W9uPgogPC94czpzaW1wbGVUeXBlPgogPHhzOmVsZW1lbnQgdHlwZT0idG5zOk1hY2hpbmVTd
        GF0ZUVudW0iIG5hbWU9Ik1hY2hpbmVTdGF0ZUVudW0iLz4KIDx4czpjb21wbGV4VHlwZSBuY
        W1lPSJMaXN0T2ZNYWNoaW5lU3RhdGVFbnVtIj4KICA8eHM6c2VxdWVuY2U+CiAgIDx4czplb
        GVtZW50IG1pbk9jY3Vycz0iMCIgbWF4T2NjdXJzPSJ1bmJvdW5kZWQiIHR5cGU9InRuczpNY
        WNoaW5lU3RhdGVFbnVtIiBuYW1lPSJNYWNoaW5lU3RhdGVFbnVtIiBuaWxsYWJsZT0idHJ1Z
        SIvPgogIDwveHM6c2VxdWVuY2U+CiA8L3hzOmNvbXBsZXhUeXBlPgogPHhzOmVsZW1lbnQgd
        HlwZT0idG5zOkxpc3RPZk1hY2hpbmVTdGF0ZUVudW0iIG5hbWU9Ikxpc3RPZk1hY2hpbmVTd
        GF0ZUVudW0iIG5pbGxhYmxlPSJ0cnVlIi8+CiA8eHM6c2ltcGxlVHlwZSBuYW1lPSJTcGluZ
        GxlU3RhdHVzIj4KICA8eHM6cmVzdHJpY3Rpb24gYmFzZT0ieHM6c3RyaW5nIj4KICAgPHhzO
        mVudW1lcmF0aW9uIHZhbHVlPSJTVE9QUEVEXzAiLz4KICAgPHhzOmVudW1lcmF0aW9uIHZhb
        HVlPSJSVU5OSU5HXzEiLz4KICA8L3hzOnJlc3RyaWN0aW9uPgogPC94czpzaW1wbGVUeXBlP
        gogPHhzOmVsZW1lbnQgdHlwZT0idG5zOlNwaW5kbGVTdGF0dXMiIG5hbWU9IlNwaW5kbGVTd
        GF0dXMiLz4KIDx4czpjb21wbGV4VHlwZSBuYW1lPSJMaXN0T2ZTcGluZGxlU3RhdHVzIj4KI
        CA8eHM6c2VxdWVuY2U+CiAgIDx4czplbGVtZW50IG1pbk9jY3Vycz0iMCIgbWF4T2NjdXJzP
        SJ1bmJvdW5kZWQiIHR5cGU9InRuczpTcGluZGxlU3RhdHVzIiBuYW1lPSJTcGluZGxlU3Rhd
        HVzIiBuaWxsYWJsZT0idHJ1ZSIvPgogIDwveHM6c2VxdWVuY2U+CiA8L3hzOmNvbXBsZXhUe
        XBlPgogPHhzOmVsZW1lbnQgdHlwZT0idG5zOkxpc3RPZlNwaW5kbGVTdGF0dXMiIG5hbWU9I
        kxpc3RPZlNwaW5kbGVTdGF0dXMiIG5pbGxhYmxlPSJ0cnVlIi8+CiA8eHM6Y29tcGxleFR5c
        GUgbmFtZT0iQXhlc1Bvc2l0aW9uIj4KICA8eHM6c2VxdWVuY2U+CiAgIDx4czplbGVtZW50I
        G1pbk9jY3Vycz0iMCIgbWF4T2NjdXJzPSIxIiB0eXBlPSJ4czpkb3VibGUiIG5hbWU9IlgxI
        i8+CiAgIDx4czplbGVtZW50IG1pbk9jY3Vycz0iMCIgbWF4T2NjdXJzPSIxIiB0eXBlPSJ4c
        zpkb3VibGUiIG5hbWU9IlkxIi8+CiAgIDx4czplbGVtZW50IG1pbk9jY3Vycz0iMCIgbWF4T
        2NjdXJzPSIxIiB0eXBlPSJ4czpkb3VibGUiIG5hbWU9IloxIi8+CiAgPC94czpzZXF1ZW5jZ
        T4KIDwveHM6Y29tcGxleFR5cGU+CiA8eHM6ZWxlbWVudCB0eXBlPSJ0bnM6QXhlc1Bvc2l0a
        W9uIiBuYW1lPSJBeGVzUG9zaXRpb24iLz4KIDx4czpjb21wbGV4VHlwZSBuYW1lPSJMaXN0T
        2ZBeGVzUG9zaXRpb24iPgogIDx4czpzZXF1ZW5jZT4KICAgPHhzOmVsZW1lbnQgbWluT2Njd
        XJzPSIwIiBtYXhPY2N1cnM9InVuYm91bmRlZCIgdHlwZT0idG5zOkF4ZXNQb3NpdGlvbiIgb
        mFtZT0iQXhlc1Bvc2l0aW9uIiBuaWxsYWJsZT0idHJ1ZSIvPgogIDwveHM6c2VxdWVuY2U+C
        iA8L3hzOmNvbXBsZXhUeXBlPgogPHhzOmVsZW1lbnQgdHlwZT0idG5zOkxpc3RPZkF4ZXNQb
        3NpdGlvbiIgbmFtZT0iTGlzdE9mQXhlc1Bvc2l0aW9uIiBuaWxsYWJsZT0idHJ1ZSIvPgo8L
        3hzOnNjaGVtYT4K</uax:ByteString>
        </Value>
    </UAVariable>
    <UAVariable DataType="String" Historizing="true" ParentNodeId="ns=1;i=6008" NodeId="ns=1;i=6009" BrowseName="NamespaceUri">
        <DisplayName>NamespaceUri</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=6008</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
        <Value>
            <uax:String>http://myorg.de/simpleModel/Types.xsd</uax:String>
        </Value>
    </UAVariable>
    <UAObjectType NodeId="ns=1;i=1003" BrowseName="1:AlarmType">
        <DisplayName>AlarmType</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty">ns=1;i=6014</Reference>
            <Reference ReferenceType="GeneratesEvent" IsForward="false">ns=1;i=1002</Reference>
            <Reference ReferenceType="HasSubtype" IsForward="false">i=2041</Reference>
            <Reference ReferenceType="HasProperty">ns=1;i=6015</Reference>
        </References>
    </UAObjectType>
    <UAVariable DataType="String" ParentNodeId="ns=1;i=1003" NodeId="ns=1;i=6014" BrowseName="1:AlarmIdentifier" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>AlarmIdentifier</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=1003</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
    </UAVariable>
    <UAVariable DataType="String" ParentNodeId="ns=1;i=1003" NodeId="ns=1;i=6015" BrowseName="1:HelpSource" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>HelpSource</DisplayName>
        <References>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=1003</Reference>
            <Reference ReferenceType="HasModellingRule">i=80</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
    </UAVariable>
    <UAObjectType NodeId="ns=1;i=1002" BrowseName="1:MachineType">
        <DisplayName>MachineType</DisplayName>
        <References>
            <Reference ReferenceType="GeneratesEvent">ns=1;i=1003</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=6012</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=7001</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=6002</Reference>
            <Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
            <Reference ReferenceType="HasProperty">ns=1;i=6001</Reference>
            <Reference ReferenceType="HasProperty">ns=1;i=6013</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=6005</Reference>
        </References>
    </UAObjectType>
    <UAVariable DataType="AxesPosition" ParentNodeId="ns=1;i=1002" NodeId="ns=1;i=6012" BrowseName="1:AxesPosition" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>AxesPosition</DisplayName>
        <References>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=1002</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=2365</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
        </References>
    </UAVariable>
    <UAMethod ParentNodeId="ns=1;i=1002" NodeId="ns=1;i=7001" BrowseName="1:EmergencyStop">
        <DisplayName>EmergencyStop</DisplayName>
        <References>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=1002</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
        </References>
    </UAMethod>
    <UAVariable DataType="MachineStateEnum" ParentNodeId="ns=1;i=1002" NodeId="ns=1;i=6002" BrowseName="1:MachineState" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>MachineState</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=2365</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=1002</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
        </References>
        <Value>
            <uax:Int32>0</uax:Int32>
        </Value>
    </UAVariable>
    <UAVariable DataType="String" ParentNodeId="ns=1;i=1002" NodeId="ns=1;i=6001" BrowseName="1:Manufacturer" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>Manufacturer</DisplayName>
        <References>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=1002</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
        </References>
    </UAVariable>
    <UAVariable DataType="String" ParentNodeId="ns=1;i=1002" NodeId="ns=1;i=6013" BrowseName="1:SerialNumber" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>SerialNumber</DisplayName>
        <References>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=68</Reference>
            <Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=1002</Reference>
        </References>
    </UAVariable>
    <UAVariable DataType="SpindleStatus" ParentNodeId="ns=1;i=1002" NodeId="ns=1;i=6005" BrowseName="1:SpindleState" UserAccessLevel="3" AccessLevel="3">
        <DisplayName>SpindleState</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=2365</Reference>
            <Reference ReferenceType="HasModellingRule">i=78</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=1002</Reference>
        </References>
    </UAVariable>
    <UAObject SymbolicName="DefaultBinary" NodeId="ns=1;i=5001" BrowseName="Default Binary">
        <DisplayName>Default Binary</DisplayName>
        <References>
            <Reference ReferenceType="HasDescription">ns=1;i=6010</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=76</Reference>
            <Reference ReferenceType="HasEncoding" IsForward="false">ns=1;i=3004</Reference>
        </References>
    </UAObject>
    <UAObject SymbolicName="DefaultXml" NodeId="ns=1;i=5002" BrowseName="Default XML">
        <DisplayName>Default XML</DisplayName>
        <References>
            <Reference ReferenceType="HasDescription">ns=1;i=6011</Reference>
            <Reference ReferenceType="HasTypeDefinition">i=76</Reference>
            <Reference ReferenceType="HasEncoding" IsForward="false">ns=1;i=3004</Reference>
        </References>
    </UAObject>
</UANodeSet>
maljac commented 8 years ago

Hi,

it seems, that the import order should be depending on the nodes ParentNodeId. I read some docs related to references etc. and my interpretation of references is, that it can happen that a reference might target a node that does not / or not yet exist. Thus, my conclusion is that the ParentNodeId is the relevant information to build a dependency tree.

The example XML is a export from UaModeler. UaModeler does not always export the nodes in the correct order (i.e. the node with id ns=1;i=6010 comes before it's parent ns=1;i=6004).

So, we could either (a) parse the xml and order the nodes according ParentNodeId or (b) try to import nodes and kind of reschedule the import. I would vote for (a) if this is possible with the current XML import and parse process.

oroulet commented 8 years ago

Is this an issue? I remember while implementing the importer that I would just create dangling references and hope that the target node would get created later.

zerox1212 commented 8 years ago

I'm not an expert with XML, but I think it would probably be easier to just check if the XML element has a ParentNodeId tag. If it does, check if that node exists, if it doesn't exist you would need to scan the XML for that specific node and create it. Then return to what you were doing. However this could have poor performance, especially if there were multiple levels of this. Might even end up with circular references...

I don't really have a good solution. Maybe a hack would be better which just imports all "parent nodes" first, then run the import again.

maljac commented 8 years ago

It turned out that its quite simple to implement. Because a node has 0 or 1 parentNodeId.

I work on a PR, will submit this evening.