Re: [Sarissa-users] Changing from updateContentFromNode
Brought to you by:
mbatsis
From: Manos B. <man...@ge...> - 2009-01-28 11:00:07
|
bryan rasmussen wrote: > I have the following bit of code: > > var bookmarkscontent = document.getElementById(target); > var xmlhttp = new XMLHttpRequest(); > xmlhttp.open("GET", uri, false); > var newString; > var oDomDoc = Sarissa.getDomDocument(); > oDomDoc.async = false; > xmlhttp.send(''); > var xslDoc = Sarissa.getDomDocument(); > xslDoc.async = false; > xslDoc.load(uritype + ".xsl"); > var processor = new XSLTProcessor(); > processor.importStylesheet(xslDoc); > Sarissa.updateContentFromNode(xmlhttp.responseXML,bookmarkscontent,processor); that can also be done with var processor = new XSLTProcessor(); processor.importStylesheet(xslDoc); Sarissa.updateContentFromURI(uri, target, processor); Maybe I should add the possibility to pass a stylesheet uri instead of a processor ;-) > > The reason for my Sarissa.updateContentFromNode choice at the end was > that basically when I tried to get the responseXML and then pass that > to the transformation and take the processed XML and then manually > updating the content node with that I kept getting errors. > Now however I am thinking about adding in functionality that will > absolutely require some post process access of the responseXML before > updating. <snip /> > resultDomDoc.selectSingleNode("/output"); // how do I do this > particular part, I need to select the document element and get out all > children that I will be appending under bookmarkscontent element. ah, right. You can use a temporary node and Sarissa.copyChildNodes: var bookmarkscontent = document.getElementById(target); var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", uri, false); var newString; var oDomDoc = Sarissa.getDomDocument(); oDomDoc.async = false; xmlhttp.send(''); var xslDoc = Sarissa.getDomDocument(); xslDoc.async = false; xslDoc.load(uritype + ".xsl"); var processor = new XSLTProcessor(); processor.importStylesheet(xslDoc); // add to a temp node for more processing var tempNode = document.createElement("div"); Sarissa.updateContentFromNode(xmlhttp.responseXML,tempNode,processor); // only copy the child nodes to the target Sarissa.copyChildNodes(tempNode, bookmarkscontent); you can append to the target or replace it's contents completely, see http://dev.abiss.gr/sarissa/jsdoc/symbols/Sarissa.html#.copyChildNodes hth, Manos |