{"action":"opened","issue":{"url":"https://api.github.com/repos/cezheng/Fuzi/issues/60","repository_url":"https://api.github.com/repos/cezheng/Fuzi","labels_url":"https://api.github.com/repos/cezheng/Fuzi/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/cezheng/Fuzi/issues/60/comments","events_url":"https://api.github.com/repos/cezheng/Fuzi/issues/60/events","html_url":"https://github.com/cezheng/Fuzi/issues/60","id":239409482,"number":60,"title":"Only namespace prefixes bound on the root node are considered by document.xpath(_ xpath: String)","user":{"login":"martin-cowie","id":3288869,"avatar_url":"https://avatars2.githubusercontent.com/u/3288869?v=3","gravatar_id":"","url":"https://api.github.com/users/martin-cowie","html_url":"https://github.com/martin-cowie","followers_url":"https://api.github.com/users/martin-cowie/followers","following_url":"https://api.github.com/users/martin-cowie/following{/other_user}","gists_url":"https://api.github.com/users/martin-cowie/gists{/gist_id}","starred_url":"https://api.github.com/users/martin-cowie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martin-cowie/subscriptions","organizations_url":"https://api.github.com/users/martin-cowie/orgs","repos_url":"https://api.github.com/users/martin-cowie/repos","events_url":"https://api.github.com/users/martin-cowie/events{/privacy}","received_events_url":"https://api.github.com/users/martin-cowie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-06-29T08:56:59Z","updated_at":"2017-06-29T08:56:59Z","closed_at":null,"body":"### Description:\r\n* Expected behaviour:\r\n\r\nXML namespaces can be bound to a prefix at any element in a document. They can be bound within an element that uses that namespace prefix. XPath expressions should be able to use the same prefixes. E.g given the document:\r\n\r\n```\r\n<root>\r\n    <u:BrowseResponse xmlns:u=\"urn:foo.bar\" />\r\n</root>\r\n```\r\nthe XPath expression `/root/u:BrowseResponse` should resolve to a nodelist of 1 element. \r\n\r\n* Actual behaviour:\r\n\r\nThe XPath expression `/root/u:BrowseResponse` resolve to a nodelist of 0 elements and the following is printed\r\n\r\n```\r\nXPath error : Undefined namespace prefix\r\nXPath error : Invalid expression\r\n```\r\n\r\nIf the document is amended such that the prefix `u:`  is bound at the root element the xpath expression evaluates correctly.\r\n\r\n### Environment\r\n* Package Manager:\r\n\t- [X] CocoaPods, version: 1.2.2\r\n* Fuzi version: 1.0.1\r\n* Xcode version: 8.3.3\r\n\r\n### How to reproduce:\r\n\r\nThe following test fails, demonstrating the issue.\r\n\r\n```\r\n    func testNestedNamespacePrefixWithXPath() {\r\n        let docStr = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><root><u:BrowseResponse xmlns:u=\\\"urn:foo.bar\\\"/></root>\"\r\n\r\n        do {\r\n            let document = try Fuzi.XMLDocument(string: docStr)\r\n            let nodes = document.xpath(\"/root/u:BrowseResponse\")\r\n            XCTAssertFalse(nodes.isEmpty)\r\n        } catch let error {\r\n            print(error)\r\n            XCTFail(String(describing:error))\r\n        }\r\n    }\r\n```"}}
{"actor":{"display_login":"martin-cowie"}}