On Mon, 22 Dec 2003 18:16:21 -0500 (EST), "XSL-List Digest"
<owner-xsl-list-digest(_at_)lists(_dot_)mulberrytech(_dot_)com> said:
From: "Andrew" <asd(_at_)ezan(_dot_)ac(_dot_)ru>
First of all- you xsl file is not well formed,xsl snippet:
<!-- The following div is referenced by the Javascript. -->
<div id="aroListing">
<xsl:apply-templates />
</div>
</table>
<!-- REQUIRES closing tags -->
</td>
</tr>
</table>
<!-- END of insertion -->
</body>
</html>
My apologies. In my haste to cutdown the files to fit into an email I
failed to provide well-formed XML and XSL. I believe the following files
are well-formed, render in the MSIE5.5 parser, and demonstrate the
problem (the HTML resulting from transformNode() fails to appear in the
<div>). NB I've placed alert() methods to demo each step of the script
working.
Thanks
Dale
-------
aro.xml
-------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="aro.xsl"?>
<arolist>
<aro>
<name> <first>Dale</first> <last>Gillard</last> </name>
<phBookURL>/phone/display_data.cfm?Id=1000000300</phBookURL>
<area>Pacific Central</area>
<areaGroup></areaGroup>
<location>Darwin</location>
<offices>
<office> <name>Area North Australia</name> <code></code> </office>
</offices>
</aro>
<aro>
<name> <first>Terry</first> <last>Towell</last> </name>
<phBookURL>/phone/display_data.cfm?Id=500002175</phBookURL>
<area>North Australia</area>
<areaGroup></areaGroup>
<location>Darwin</location>
<offices>
<office> <name>Area North Australia</name> <code></code> </office>
</offices>
</aro>
</arolist>
-------
xsl.js
-------
function sortWithValue(aSortValue)
{
theXMLDoc = document.XMLDocument;
theXSLDoc = document.XSLDocument;
var node = theXSLDoc.selectSingleNode( "//xsl:sort/@select" );
node.nodeValue = aSortValue;
alert("The new sort value is: " + node.nodeValue);
var html = theXMLDoc.documentElement.transformNode(theXSLDoc);
alert("The original innerHTML is:\n" + aroListing.innerHTML);
// The following line fails to update the document,
// even though alert() methods show transformNode() returned the
expected HTML.
alert("The HTML returned from transformNode() is:\n" + html);
aroListing.innerHTML = html;
alert("The updated innerHTML is:\n" + aroListing.innerHTML);
}
-------
aro.xsl
-------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<title>ARONET - ARO Contacts</title>
<link rel="stylesheet" href="/stylesheets/corp.css" />
<script type="text/javascript" src="/stylesheets/keystroke.js"></script>
<!-- The externally linked Javascript file used to change the XSLT
sort/@select attribute. -->
<script type="text/javascript" src="xsl.js"></script>
</head>
<body>
<h1 title="Authorised Review Officer Contacts">ARO Contacts</h1>
<table width="95%" border="0" align="center" cellpadding="5"
cellspacing="0">
<tr>
<td class="euc40">
<div id="areaCell" style="cursor:hand" onClick="sortWithValue('area')">
<strong>Area</strong>
</div>
</td>
<td class="euc40">
<div id="nameCell" style="cursor:hand"
onClick="sortWithValue('name/last')">
<strong>Name</strong>
</div>
</td>
<td class="euc40"><strong>Location</strong></td>
<td class="euc40"><strong>Does reviews for</strong></td>
</tr>
<!-- The following div is referenced by the Javascript. -->
<div id="aroListing">
<xsl:apply-templates />
</div>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="arolist">
<xsl:apply-templates select="aro">
<xsl:sort select="area" order="ascending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="aro">
<tr>
<xsl:apply-templates select="area"/>
<xsl:apply-templates select="name"/>
<td valign="top" class="euc20" style="white-space:nowrap"><xsl:value-of
select="location"/></td>
<xsl:apply-templates select="offices"/>
</tr>
</xsl:template>
<xsl:template match="area">
<td valign="top" class="euc20" style="white-space:nowrap">
<xsl:value-of select="."/><br />
<xsl:apply-templates select="../areaGroup"/>
</td>
</xsl:template>
<xsl:template match="areaGroup">
<div style="font:0.75em;color:gray" title="Area Group or Cluster.">
<xsl:value-of select="."/>
</div>
</xsl:template>
<xsl:template match="name">
<td valign="top" class="euc20" style="white-space:nowrap">
<a title="Link to Centrelink Phone Book entry.">
<xsl:attribute name="href">
<xsl:value-of select="../phBookURL"/>
</xsl:attribute>
<xsl:value-of select="."/>
</a>
</td>
</xsl:template>
<xsl:template match="offices">
<td valign="top" class="euc20">
<xsl:for-each select="office">
<xsl:sort select="name" order="ascending"/>
<xsl:value-of select="name"/>
<xsl:if test="string(code)">
(<xsl:value-of select="code"/>)<br/>
</xsl:if>
</xsl:for-each>
</td>
</xsl:template>
</xsl:stylesheet>
-----------------
--
Dale Gillard
dalegillard(_at_)fastmail(_dot_)fm
--
http://www.fastmail.fm - Access all of your messages and folders
wherever you are
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list