Jump to content

Redirecting XSLT result to a new HTML page


centaur

Recommended Posts

I am new to using XML and XSLT.I am using XSLT to transform to handle a server's XML response and transform it into XHTML.I need to redirect the transformed html document to a new html page. Is it possible to do so??Currently I am able to store the transformation in a <div> element of the same page using:<......code....>if (window.ActiveXObject) { var result = req.transformNode(xsl); document.getElementById("xslhtmcontent").innerHTML = result; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(req,document); document.getElementById("xslhtmcontent").appendChild(resultDocument); }</....code....>The problem with this approach is that due to this my original html code for the current page is lost which I might require as I further develop the application.One more issue that needs to be resolved is that shoul I keep my XSL file on the client and directly load it using: < xslt.load("Beatles.xsl");> or should I keep it on server and then request the server to return the xslt code when requested by using: <xsl=loadXMLDoc("transform.xsl");>Please Help...!!!Thanks in advance. :)--Centaur

Link to comment
Share on other sites

I don't see how code is lost with your Mozilla code branch as there you do an appendChild and that way you simply add content. In the IE code branch you set the innerHTML of an element, that way you overwrite the element's content, if you don't want to do that then use

  document.getElementById('xslhtmlcontent').insertAdjacentHTML('beforeEnd', result);

instead of the innerHTML assignment.

Link to comment
Share on other sites

I don't see how code is lost with your Mozilla code branch as there you do an appendChild and that way you simply add content. In the IE code branch you set the innerHTML of an element, that way you overwrite the element's content, if you don't want to do that then use
  document.getElementById('xslhtmlcontent').insertAdjacentHTML('beforeEnd', result);

instead of the innerHTML assignment.

Thank you very much.I will try out the code snippet provided by you. :) By losing the code I meant that I am having to overwrite on the same html page.Thanks you.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...