{"action":"created","issue":{"url":"https://api.github.com/repos/open62541/open62541/issues/825","repository_url":"https://api.github.com/repos/open62541/open62541","labels_url":"https://api.github.com/repos/open62541/open62541/issues/825/labels{/name}","comments_url":"https://api.github.com/repos/open62541/open62541/issues/825/comments","events_url":"https://api.github.com/repos/open62541/open62541/issues/825/events","html_url":"https://github.com/open62541/open62541/issues/825","id":179787207,"number":825,"title":"Wrong namespace URI in pyUANamespace compiler","user":{"login":"Pro","id":251973,"avatar_url":"https://avatars.githubusercontent.com/u/251973?v=3","gravatar_id":"","url":"https://api.github.com/users/Pro","html_url":"https://github.com/Pro","followers_url":"https://api.github.com/users/Pro/followers","following_url":"https://api.github.com/users/Pro/following{/other_user}","gists_url":"https://api.github.com/users/Pro/gists{/gist_id}","starred_url":"https://api.github.com/users/Pro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pro/subscriptions","organizations_url":"https://api.github.com/users/Pro/orgs","repos_url":"https://api.github.com/users/Pro/repos","events_url":"https://api.github.com/users/Pro/events{/privacy}","received_events_url":"https://api.github.com/users/Pro/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/open62541/open62541/labels/namespace-compiler","name":"namespace-compiler","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-28T14:21:19Z","updated_at":"2016-09-28T16:32:55Z","closed_at":"2016-09-28T16:32:55Z","body":"I used UaModeler to create a new model which is based on NS0 and [Opc.Ua.Di.NodeSet2.xml](https://opcfoundation.org/UADevices/1.1/Opc.Ua.Di.NodeSet2.xml, called `project1.NodeSet2.xml`\r\n\r\nIn UaModeler I entered for the namespace URI:\r\n`http://yourorganisation.org/project2/`\r\n\r\nThis generates the following .xml file:\r\n\r\n```\r\n<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://yourorganisation.org/project1/Types.xsd\" xmlns:s2=\"http://opcfoundation.org/UA/DI/Types.xsd\" xmlns:ua=\"http://unifiedautomation.com/Configuration/NodeSet.xsd\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n    <NamespaceUris>\r\n        <Uri>http://yourorganisation.org/project1/</Uri>\r\n        <Uri>http://opcfoundation.org/UA/DI/</Uri>\r\n    </NamespaceUris>\r\n    ...\r\n```\r\n\r\nNote:\r\n* `xmlns:s1` is set to \"http://yourorganisation.org/project1/Types.xsd\" \r\n* `<NamespaceUris>` contains `http://yourorganisation.org/project1/`\r\n\r\nAnd the generated .c file contains:\r\n```\r\nUA_Server_addNamespace(server, \"http://yourorganisation.org/project1/Types.xsd\");\r\n```\r\n\r\nThis means that the namespace URI is wrong, i.e. it should be:\r\n```\r\nUA_Server_addNamespace(server, \"http://yourorganisation.org/project1/\");\r\n```\r\n\r\nThis is caused by the following lines (https://github.com/open62541/open62541/blob/0.2/tools/pyUANamespace/open62541_XMLPreprocessor.py#L168)\r\n\r\n```\r\n    # Might be the more reliable method: Get the URI from the xmlns attributes (they have numers)\r\n    if len(self.namespaceOrder) > 0:\r\n     for el in self.namespaceOrder:\r\n       if el[0] == nsId:\r\n         return el[1]\r\n```\r\n\r\nThe `namespaceOrder` contains the namespace with `Types.xsd`. This also causes that (https://github.com/open62541/open62541/blob/0.2/tools/pyUANamespace/open62541_XMLPreprocessor.py#L332)\r\n```\r\nif tgt.getReferencedNamespaceUri(1) == nsUri:\r\n```\r\nwill never be true and thus it falls back to the stochastic method, which shouldn't happen.\r\n\r\nIf I remove the lines with `namespaceOrder` everything works as expected.\r\n\r\nWhat's the purpose of the `namespaceOrder`?\r\n\r\nRelated to #823 "},"comment":{"url":"https://api.github.com/repos/open62541/open62541/issues/comments/250221838","html_url":"https://github.com/open62541/open62541/issues/825#issuecomment-250221838","issue_url":"https://api.github.com/repos/open62541/open62541/issues/825","id":250221838,"user":{"login":"Pro","id":251973,"avatar_url":"https://avatars.githubusercontent.com/u/251973?v=3","gravatar_id":"","url":"https://api.github.com/users/Pro","html_url":"https://github.com/Pro","followers_url":"https://api.github.com/users/Pro/followers","following_url":"https://api.github.com/users/Pro/following{/other_user}","gists_url":"https://api.github.com/users/Pro/gists{/gist_id}","starred_url":"https://api.github.com/users/Pro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pro/subscriptions","organizations_url":"https://api.github.com/users/Pro/orgs","repos_url":"https://api.github.com/users/Pro/repos","events_url":"https://api.github.com/users/Pro/events{/privacy}","received_events_url":"https://api.github.com/users/Pro/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T16:32:55Z","updated_at":"2016-09-28T16:32:55Z","body":"Fixed with commit https://github.com/open62541/open62541/commit/dd29beee3d7bca9e6dbad7f297dad7d74260cbb1"}}
{"actor":{"display_login":"Pro"}}