[webkit-dev] createNSResolver and namespaced XPath
Paul Everitt
paul at zeapartners.org
Sat May 20 13:01:50 PDT 2006
Howdy all. First and foremost, thanks a ton for 6638:
http://bugzilla.opendarwin.org/show_bug.cgi?id=6638
I'm working on some XForms inspired stuff. 6638 is important for the
ideas I'm trying out.
I also saw 8791:
http://bugzilla.opendarwin.org/show_bug.cgi?id=8791
...and I'm sticking to createNSResolver for now. However, I can't get
it to work with namespaced XPath expressions. For example the following
matches nothing:
<html>
<head>
<title>XPath Resolver in WebKit</title>
<script>
function search (xpath) {
var xmlString = '<xf:model xmlns:xf="http://foo.org/"/>';
// Make a doc and a resolver
var doc = (new DOMParser()).parseFromString(xmlString, "text/xml");
var contextNode = doc.documentElement;
var nsResolver = document.createNSResolver(contextNode);
// Evaluate a namespaced xpath
var result = doc.evaluate('//xf:model', doc, nsResolver,
null, null);
alert(result.iterateNext().tagName);
}
</script>
</head>
<body>
<h1>XPath resolver in WebKit</h1>
<p>This page test the XPath .evaluate function in WebKit, in
particular, looking up XPath expressions in foreign namespaces
with <code>createNSResolver</code>.</p>
<p><button onclick="search('//*');">Test</button></p>
</body>
</html>
This test case is also at the following URL:
http://zeapartners.org/~paul/xpathresolver.html
It works in Firefox, giving "xf:model" as the alert, but "null" in a
nightly WebKit (from yesterday). I certainly expect that I'm doing
something wrong...
Thanks for the help!
--Paul
More information about the webkit-dev
mailing list