There are a number of points:
1) Remember that XPath is case sensitive, you have "Book/Title" and "book/title", these must match your blank xml.
2) You are using an older form of XPath wheeled out by Microsoft before the current standards were finalised. I think the first test should be written:
Code:
<xsl:when test="/book/Title[. != '']">
This extracts all the book/Title nodes where the Title's text is not blank and gives Boolean negative if the set is empty. Assuming you are always only going to have one book element then this works.
3) You are using a stylesheet format that is rarely used and I'm not sure IE can recognise. You're safer putting in the full tags:
Code:
<xml id="bookXSL"><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<div>
<xsl:choose>
<xsl:when test="/book/Title[. != '']">
<table border="0" cellpadding="1">
<tr>
<td>Title:</td>
<td><xsl:value-of select="/book/Title"/></td>
</tr>
<tr>
<td>Publisher:</td>
<td><xsl:value-of select="/book/publisher"/></td>
</tr>
<tr>
<td>Published Date:</td>
<td><xsl:value-of select="/book/pubDate"/></td>
</tr>
<tr>
<td>Abstract:</td>
<td><xsl:value-of select="/book/abstract"/></td>
</tr>
<tr>
<td>Pages:</td>
<td><xsl:value-of select="/book/pages"/></td>
</tr>
<tr>
<td>ISBN:</td>
<td><xsl:value-of select="/book/isbn"/></td>
</tr>
<tr>
<td>Price:</td>
<td><xsl:value-of select="/book/price"/></td>
</tr>
</table>
</xsl:when>
<xsl:otherwise>
<p>Book Information not yet specified.</p>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
</xsl:stylesheet>
Again check the capitalisation.
4)When asked for a DomDocument IE gives the latest version upto version 2.6 or version 3 if installed in replace mode. See MSDN for more details if you wish. If you are sure that parser version 3 is available you are better off creating your own parser when needed:
Code:
var oStyle = new ActiveXObject("Msxml2.DomDocument.3.0");
oStyle.async = false;
oStyle.setProperty("SelectionLanguage", "XPath");
oStyle.load(xslBook.XMLDocument);
If you know version 4 is available then use that:
Code:
var oStyle = new ActiveXObject("Msxml2.DomDocument.4.0");
oStyle.async = false;
oStyle.load(xslBook.XMLDocument);
It doesn't need the other line as it doesn't support XSLPattern.
I usually use a function to return a new DomDocument when needed.
--
Joe