aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xmerl/src
diff options
context:
space:
mode:
authorDaniel White <[email protected]>2013-09-13 00:22:47 +1000
committerFredrik Gustafsson <[email protected]>2013-11-04 16:02:21 +0100
commit3702a386fd0121bde1b1d02c65de66245e9518cc (patch)
treed0c0daad55afb390ea4fded317a30a28b80b76ac /lib/xmerl/src
parentf041ece67a75593c39d36c3ef968556214e2b126 (diff)
downloadotp-3702a386fd0121bde1b1d02c65de66245e9518cc.tar.gz
otp-3702a386fd0121bde1b1d02c65de66245e9518cc.tar.bz2
otp-3702a386fd0121bde1b1d02c65de66245e9518cc.zip
xmerl: Use context namespace declarations to resolve prefix node tests
Previously, a match would not be found if the namespace prefix in the XPath query was not contained in the original document. This allows the `namespace' option to provide a prefix that will be resolved to a namespace URI. See Section 2.3 of the XPath 1.0 specification for the behaviour of 'NCName:*' node tests.
Diffstat (limited to 'lib/xmerl/src')
-rw-r--r--lib/xmerl/src/xmerl_xpath.erl22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/xmerl/src/xmerl_xpath.erl b/lib/xmerl/src/xmerl_xpath.erl
index 9af632e9ac..be0e863ce4 100644
--- a/lib/xmerl/src/xmerl_xpath.erl
+++ b/lib/xmerl/src/xmerl_xpath.erl
@@ -713,10 +713,26 @@ node_test(_Test,
node_test({wildcard, _}, #xmlNode{type=ElAt}, _Context)
when ElAt==element; ElAt==attribute; ElAt==namespace ->
true;
-node_test({prefix_test, Prefix}, #xmlNode{node = N}, _Context) ->
+node_test({prefix_test, Prefix}, #xmlNode{node = N}, Context) ->
case N of
- #xmlElement{nsinfo = {Prefix, _}} -> true;
- #xmlAttribute{nsinfo = {Prefix, _}} -> true;
+ #xmlElement{nsinfo = {Prefix, _}} ->
+ true;
+ #xmlElement{expanded_name = {Uri, _}} ->
+ case expanded_name(Prefix, "_", Context) of
+ {Uri, _} ->
+ true;
+ _ ->
+ false
+ end;
+ #xmlAttribute{nsinfo = {Prefix, _}} ->
+ true;
+ #xmlAttribute{expanded_name = {Uri, _}} ->
+ case expanded_name(Prefix, "_", Context) of
+ {Uri, _} ->
+ true;
+ _ ->
+ false
+ end;
_ ->
false
end;