I have a html file embedded xml tags inside, here i am trying to apply xslt styles are written in another separate file (somefile.xsl) importing with javascript, i am successful applying styles with external xslt file importing with javascript but it is working only in internet explorer , other browsers failed to apply styles.. bellow is my html code please look at my code. where i am doing wrong here ? Except IE no other browser seem working with these technique.
<HTML>
<HEAD>
<TITLE>Sample XML with XSL</TITLE>
<xml id="elx">
<hello-world>
<greeter>An XSLT Programmer</greeter>
<greeting>Hello, World! </greeting>
</hello-world>
</xml>
</HEAD>
<BODY>
<SCRIPT language = "javascript">
if(window.ActiveXObject)
{
//IE
alert("hi");
var xslDoc = new ActiveXObject("Microsoft.XMLDOM");
xslDoc.async = false;
xslDoc.load("helloworld.xsl");
document.write(elx.transformNode(xslDoc));
}
else if (document.implementation && document.implementation.createDocument)
{
//For Other Browsers
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet("helloworld.xsl");
result = xsltProcessor.transformToDocument(elx);
// here 'elx' is id of embedded xml in header.
document.write(result);
}
</SCRIPT>
</BODY>
</HTML>
and here is my xsl ( helloworld.xsl ) file which i am trying to import with javascript and adding styles to embedded xml inside html file
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="html" version="1.1" encoding="iso-8859-1" />
<xsl:template match="/hello-world">
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
<H1>
<xsl:value-of select="greeting"/>
</H1>
<xsl:apply-templates select="greeter"/>
</BODY>
</HTML>
</xsl:template>
within my html file i get only id of that xml file, by using that xml id i need to apply styles using javascript. hope you understand my issue and please solve this as soon as possible.