[Project_owners] Re: Using XPath to validate fields

Axel Hecht axel at pike.org
Thu Mar 31 19:03:45 EST 2005


> 
> David,
> 
> You might consider changing:
>   textboxes[z].focus();
> to something like
>   textboxes[z].setAttribute("style", "background: red; color:
> white");
> to make them stand out.
> 
> Also, I've updated the XPath code sample on kb.mozillazine.org to
> work with code like yours (I think -- would appreciate it if you
> could try it out again). I'm the one who wrote that article
> originally.
> 

The code still lacks any hint on what to do if your XML document is 
using a default namespace.

<foo xmlns="http://some.domain.tld/bar">
  <bar/>
</foo>

and /foo/bar will not match, you will need to do something like

/p:foo/p:bar and use
function resolver(aPrefix) {
   if (aPrefix == "p") {
     return "http://some.domain.tld/bar";
   }
   return "";
}

as resolver. You can't use a resolver created from a node.

Axel


More information about the Project_owners mailing list