XSLT transformation from XML buffer and XSL file
Hi,
I'm trying to transform a xml buffer using an xsl file in javascript. I'm used "transformToDocument / transformToFragment " methods . Everthing works as long as the xml and xsl are kept as files.
If i use xmlhttp to load the xml file and place it in a buffer and use an xsl file to transform it then, the problem occurs.
The Problem i'm facing is , The xsl file is show as html in the firefox browser. But there is no xml data shown. I'm pasting the code i'm using here.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
var myDOM;
var xmlDoc;
// load the xslt file, example1.xsl
var myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", "example1.xsl", false);
myXMLHTTPRequest.send(null);
xslStylesheet = myXMLHTTPRequest.responseXML;
xsltProcessor.importStylesheet(xslStylesheet);
theData = document.getElementById("response_t").value; // the xml data is placed in the textare for testing.
var domParser = new DOMParser();
var xmlDocument = domParser.parseFromString(theData,'application/xml');
doc = xsltProcessor.transformToDocument(xmlDocument);
var xmls = new XMLSerializer();
document.getElementById("example").innerHTML = (xmls.serializeToString(doc));
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF" onload="test()">
<textarea cols=80 rows="10" id="response_t" style="visibility:hidden;display:none;"></textarea>
<div id="example"></div>
</BODY>
</HTML>
sorry again to repeat. The transformation is good when we are using the xml from a file for transforming. If it is placed in a buffer then the xsl is shown in the browser but with no xml data. This problem is only in the Firefox browser
Thanks in advance.
Kumar S
|