diff options
author | Daniel White <[email protected]> | 2013-09-12 23:55:48 +1000 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-11-04 16:02:21 +0100 |
commit | f041ece67a75593c39d36c3ef968556214e2b126 (patch) | |
tree | 2d734d3dd11a202a0bd51fffaeab2bd10784788b /lib | |
parent | 83ba8e6a9cc704bb3713b0a8f4e8c8a71b6dea0a (diff) | |
download | otp-f041ece67a75593c39d36c3ef968556214e2b126.tar.gz otp-f041ece67a75593c39d36c3ef968556214e2b126.tar.bz2 otp-f041ece67a75593c39d36c3ef968556214e2b126.zip |
xmerl: Look up unknown prefixes in xmlContext when matching attributes
The core use case is a query where the original prefix in the scanned
document is unknown (or varying). For example:
xmerl_xpath:scan("//@ns:name", Doc, [{namespace, [{"ns", Uri}]}])
Previously, this would only return a result if the namespace prefix
was an exact match.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xmerl/src/xmerl_xpath.erl | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/xmerl/src/xmerl_xpath.erl b/lib/xmerl/src/xmerl_xpath.erl index b3301f2faf..9af632e9ac 100644 --- a/lib/xmerl/src/xmerl_xpath.erl +++ b/lib/xmerl/src/xmerl_xpath.erl @@ -760,20 +760,21 @@ node_test({name, {_Tag, Prefix, Local}}, node_test({name, {Tag,_Prefix,_Local}}, #xmlNode{node = #xmlAttribute{name = Tag}}, _Context) -> true; -node_test({name, {_Tag, Prefix, Local}}, - #xmlNode{node = #xmlAttribute{expanded_name = {URI, Local}, - nsinfo = {_Prefix1, _}, - namespace = NS}}, _Context) -> - NSNodes = NS#xmlNamespace.nodes, - case lists:keysearch(Prefix, 1, NSNodes) of - {value, {_, URI}} -> - ?dbg("node_test(~, ~p) -> true.~n", - [{_Tag, Prefix, Local}, write_node(NSNodes)]), - true; - false -> - ?dbg("node_test(~, ~p) -> false.~n", - [{_Tag, Prefix, Local}, write_node(NSNodes)]), - false +node_test({name, {Tag, Prefix, Local}}, + #xmlNode{node = #xmlAttribute{name = Name, + expanded_name = EExpName + }}, Context) -> + case expanded_name(Prefix, Local, Context) of + [] -> + Res = (Tag == Name), + ?dbg("node_test(~p, ~p) -> ~p.~n", + [{Tag, Prefix, Local}, write_node(Name), Res]), + Res; + ExpName -> + Res = (ExpName == EExpName), + ?dbg("node_test(~p, ~p) -> ~p.~n", + [{Tag, Prefix, Local}, write_node(Name), Res]), + Res end; node_test({name, {_Tag, [], Local}}, #xmlNode{node = #xmlNsNode{prefix = Local}}, _Context) -> |