xsl-list
[Top] [All Lists]

Re: transformNode() and innerHTML combo fail to update

2003-12-23 21:58:21
Thanks Andrew, I'll try the solution. Having read the MS document 'How to
build tables dynamically' you referred to I can see why my Javascript
wasn't loading the transformed HTML - innerHTML is read only for tables.

I understood the "<xml></xml>" tag to be proprietary to MSIE (as is my
'document.XMLDocument' reference in the Javascript. Is this the case? I'm
trying to avoid using proprietary features of IE5.5 as it only supported
the XML/XSL W3C draft, and my employer will be moving to IE6 mid 2004
(which supports the W3C recommendations for XML/XSL) and I want my code
to be compatible with this.

Would it be possible/simpler to use the just the DOM to traverse the
original XSL tree and replace/remove the "//xsl:sort/@select" node? That
is, I believe that IE 5.5 supports the DOM 1 specification, but I'm not
sure it would update the displayed document following the change to the
sort's select attribute?

Thanks again.

Dale

On Tue, 23 Dec 2003 13:22:36 +0300, Andrew said:
OK, you want to manipulate table's content dynamically:
1) read this
http://msdn.microsoft.com/workshop/author/tables/buildtables.asp
2) you're using div(aroListing) element as direct child of table-it seems
you need to use tbody instead and add rows to it through insertRow() etc.
see (1)

Suggested solution(something like):
1) replace div(aroListing) on tbody
2)add to document another xml doc(aro.xsl):
...
<head>
   <xml id="test"></xml>
    ...
</head>
...
3) in (xsl.js)/sortWithValue instead of //aroListing.innerHTML = html;:

function sortWithValue(aSortValue)
{
  theXMLDoc = document.XMLDocument;
  theXSLDoc = document.XSLDocument;
  //----------  insert
  m= theXSLDoc.selectSingleNode( "//*[(_at_)method='html']");
  if(m){
   m.setAttribute( "method", "xml");
   m.setAttribute( "omit-xml-declaration", "yes");
  }
  //----------end

  var node = theXSLDoc.selectSingleNode( "//xsl:sort/@select" );
  node.nodeValue = aSortValue;
  var html = theXMLDoc.documentElement.transformNode(theXSLDoc);
  //--------------------- insert

  newAro= document.createElement( "TBODY");
  aroListing.parentElement.appendChild( newAro);
  aroListing.removeNode( true);
  newAro.id= "aroListing";

  test.loadXML( "<tbody>"+html+"</tbody>");
  rs= test.documentElement.childNodes;
  for( i= 0; i< rs.length; i++){
   r= aroListing.insertRow();
   cl= rs[i].childNodes;
   for( j= 0; j< cl.length; j++)
                  r.insertCell().innerHTML= cl[j].xml;
  }
  //------------------------ end
  //aroListing.innerHTML = html;
}
-- 
  Dale Gillard
  dalegillard(_at_)fastmail(_dot_)fm

-- 
http://www.fastmail.fm - Choose from over 50 domains or use your own

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list