[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: transformNode() and innerHTML combo fail to update

Subject: Re: transformNode() and innerHTML combo fail to update
From: "Dale Gillard" <dalegillard@xxxxxxxxxxx>
Date: Tue, 23 Dec 2003 10:42:40 +1000
transformnode
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
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@xxxxxxxxxxx

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.