Re: Keyboard Navigation Code - XPathEvaluate - need help

"Ady Shimony" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Another Netscape Collabra Server User
Message-ID <ctslde$e1j1__30827.9181168929$1107417561$gmane$org@ripley.netscape.com>
Thanks martin

That helped - the code is working and I manage to make it work with XUl

Thanks a lot!

Adys

"Martin Honnen" <[email protected]> wrote in message 
news:[email protected]...
>
>
> Ady Shimony wrote:
>
>
>> My XUL looks like this
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <?xml-stylesheet href="/css/default_PC.css" type="text/css"?>
>> <window width="602" height="452" style="background: #FFFFFF;" 
>> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
>> title="Screen2" UserEdit="yes" align="left">
>> <stack>
>> <button id="Button1" width="80" height="28" left="44" top="41" 
>> style="background: #5F6BA7;border-color: #6E7AB0;" label="My 
>> Button"></button>
>> <button id="Button2" width="80" height="28" left="155" top="40" 
>> style="background: #5F6BA7;border-color: #6E7AB0;" label="My 
>> Button"></button>
>> <button id="Button3" width="80" height="28" left="249" top="37" 
>> style="background: #5F6BA7;border-color: #6E7AB0;" label="My 
>> Button"></button>
>> </stack>
>> </window>
>>
>> I don't understand how to make the resolver undertand ?
>
> Here is a working example, the prefix 'xul' is bound to the XUL namespace 
> so that in XPath expression you can use 'xul:xulelementname' e.g. 
> 'xul:button' to access XUL elements:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <window width="602" height="452" style="background: #FFFFFF;"
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
> xmlns:xhtml="http://www.w3.org/1999/xhtml"
> title="Screen2" align="left">
> <script type="text/javascript">
> <![CDATA[
> function testXPathEvaluation () {
>   var resolver = document.createNSResolver(document.documentElement);
>   var xpathResult = document.evaluate(
>     '//xul:button | //xhtml:input',
>     document,
>     function lookupNamespaceURI (prefix) {
>       var nsURI = null;
>       switch (prefix) {
>         case 'xul':
>           nsURI = 
> 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul';
>           break;
>         default:
>           nsURI = resolver.lookupNamespaceURI(prefix);
>           break;
>       }
>       return nsURI;
>     },
>     XPathResult.ORDERED_NODE_ITERATOR_TYPE,
>     null
>   );
>   var result = '';
>   var node;
>   while ((node = xpathResult.iterateNext())) {
>     result += 'nodeType: ' + node.nodeType + '; nodeName: ' + 
> node.nodeName + '\r\n';
>   }
>   alert(result);
> }
> ]]>
> </script>
> <stack>
> <button id="Button1" width="80" height="28" left="44" top="41"
> style="background: #5F6BA7;border-color: #6E7AB0;" label="My 
> Button"></button>
> <button id="Button2" width="80" height="28" left="155" top="40"
> style="background: #5F6BA7;border-color: #6E7AB0;" label="My 
> Button"></button>
> <button id="Button3" width="80" height="28" left="249" top="37"
> style="background: #5F6BA7;border-color: #6E7AB0;" label="My 
> Button"></button>
> <xhtml:input type="button" value="html click button" 
> onclick="testXPathEvaluation();"/>
> </stack>
> </window>
>
> As said the problem with XPath (XPath 1.0) is that any XPath expression 
> trying to access elements in the default namespace (e.g. <element 
> xmlns="http://example.com/whatever">) needs to use a prefix bound to that 
> namespace.
>
> -- 
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.