Re: [xsl] transformNode() and innerHTML combo fail to update

Subject: Re: [xsl] transformNode() and innerHTML combo fail to update
From: "Dale Gillard" <dalegillard@xxxxxxxxxxx>
Date: Tue, 23 Dec 2003 10:42:40 +1000
On Mon, 22 Dec 2003 18:16:21 -0500 (EST), "XSL-List Digest"
<owner-xsl-list-digest@xxxxxxxxxxxxxxxxxxxxxx> said:

> From: "Andrew" <asd@xxxxxxxxxx>
> 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



<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="aro.xsl"?> 
<name> <first>Dale</first> <last>Gillard</last> </name>
<area>Pacific Central</area>
	<office> <name>Area North Australia</name> <code></code> </office>
<name> <first>Terry</first> <last>Towell</last> </name>
<area>North Australia</area>
	<office> <name>Area North Australia</name> <code></code> </office>
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);
<?xml version="1.0"?> 
<xsl:stylesheet version="1.0"
<xsl:output method="html" />
<xsl:template match="/">
<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>
<h1 title="Authorised Review Officer Contacts">ARO Contacts</h1>
<table width="95%" border="0" align="center" cellpadding="5"
<td class="euc40">
<div id="areaCell" style="cursor:hand" onClick="sortWithValue('area')">
<td class="euc40">
<div id="nameCell" style="cursor:hand"
<td class="euc40"><strong>Location</strong></td>
<td class="euc40"><strong>Does reviews for</strong></td>
<!-- The following div is referenced by the Javascript. -->
<div id="aroListing">
  <xsl:apply-templates />

<xsl:template match="arolist">
  <xsl:apply-templates select="aro">
    <xsl:sort select="area" order="ascending"/>

<xsl:template match="aro">
  <xsl:apply-templates select="area"/>
  <xsl:apply-templates select="name"/>
  <td valign="top" class="euc20" style="white-space:nowrap"><xsl:value-of
  <xsl:apply-templates select="offices"/>

<xsl:template match="area">
  <td valign="top" class="euc20" style="white-space:nowrap">
  <xsl:value-of select="."/><br />
  <xsl:apply-templates select="../areaGroup"/>

<xsl:template match="areaGroup">
  <div style="font:0.75em;color:gray" title="Area Group or Cluster.">
  <xsl:value-of select="."/>

<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:value-of select="."/>

<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/>

  Dale Gillard

-- - Access all of your messages and folders
                          wherever you are

 XSL-List info and archive:

Current Thread