XPath difference between <xsl:output method="html"> and "xml"
"C.W.Holeman II" <[email protected]> Wed, 11 Apr 2007 22:12:31 -0800
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Message-ID | <[email protected]> |
I am using Firefox 2.0.0.3 on MSWindows.
I have an XML file http://emle.sourceforge.net/emle020000/zh.xml :
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="zh.xsl" type="text/xsl"?>
<z xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
which invokes an XSLT file http://emle.sourceforge.net/emle020000/zh.xsl
that starts with an output method of "html". The result invokes
a JavaScript function that has an XPath string of "//body".
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
encoding="iso-8859-1"
indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>
<xsl:template match="/z">
<html>
...
var body = document.evaluate("//body",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
.singleNodeValue;
alert(" body" + document.childNodes[1].childNodes[1] + ": " + body);
...
The result is a popup that displays the string "[object HTMLBodyElement]"
for the variable body which seems reasonable.
I then modify the files resulting in
http://emle.sourceforge.net/emle020000/zx.xml
http://emle.sourceforge.net/emle020000/zx.xsl . I changed the output method
from
"html" to "xml" and added an xmlns attribute to the html element of
"http://www.w3.org/1999/xhtml" .
The popup then display "null" for the value of body for the same XPath
string
"//body"
How do I locate the body element with XPath?
--
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