Re: XPath difference between <xsl:output method="html"> and "xml"

"C.W.Holeman II" <[email protected]> Thu, 12 Apr 2007 06:28:57 -0800
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Message-ID <[email protected]>
"Martin Honnen" <[email protected]> wrote in message 
news:[email protected]...
> C.W.Holeman II wrote:
>
>> How do I locate the body element with XPath?
>
> With XPath 1.0 if you have a path
>   element-name
> (or e.g. body) then the XPath expression selects elements of that name 
> (e.g element-name or body) in _no_ namespace while XHTML elements are in 
> the namespace http://www.w3.org/1999/xhtml. To select elements in a 
> namespace you need to bind a prefix (e.g. 'xhtml) to the namespace URI and 
> use that prefix in your expression (e.g. xhtml:body). So with the W3C DOM 
> Level 3 XPath API you use a namespace resolver as follows
>
> var body = document.evaluate(
>   "//xhtml:body",
>   document,
>   function lookupNamespaceURI (prefix) {
>     switch (prefix) {
>       case 'xhtml':
>         return 'http://www.w3.org/1999/xhtml';
>     }
>   }, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

I attempted to put that directly in and got the same results of "null"
for body. I do not see any prefix of "xhtml" in the code so I thought
the value of prefix in the case statement may not be correct. For a test I 
changed
it to ignore the argument and just return the string 
'http://www.w3.org/1999/xhtml'.
I got the same results. I then added an alert to display the string.

  lu = function lookupNamespaceURI (prefix) {return 
'http://www.w3.org/1999/xhtml';};
  alert(lu());
  var body = document.evaluate("//body",
   document, lu, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
   .singleNodeValue;

The new files are at:
http://emle.sourceforge.net/emle020000/zx2.xml
http://emle.sourceforge.net/emle020000/zx2.xsl

-- 
C.W.Holeman II | [email protected] -5 | http://JulianLocals.com/cwhii
 To only a fraction of the  human  race does God  give the  privilege of
 earning one's bread doing what one would have  gladly pursued free, for
 passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks