Jump to content

How can I load an XSL file from another server?


Zamolxe

Recommended Posts

I have one big problem.I have made an Html doc in wich using xml and xsl via javascript I load the xml file and using the xsl I genrate a table from it.I have made the script run both on IE and Mozilla it runs perfect in on PC but when I have tried to upload the html xml and xsl fil on a server the IE ver runs ok but on mozilla the transform from xsl does't work.I was :) wtf... I have tried to put in the url path on my pc the exact path to my xsl c:\test\test.xslin IE and in Mozilla you know it loads somewhat formated and we can tell that the file is recognized I don't know how to explain.On my server www.test.com/test/test.xsl on IE is ok but on Mozilla it loads like plain txt.So I figured that this could be the problem but I hevent heard of this kind of problem before.Can u help.Thx

Link to comment
Share on other sites

Hi thx for the reply... here is the info about the code.The link for the xsl ishttp://www.agrimob.ro/produse/Produse.xslhttp://www.agrimob.ro/produse/Produse.xmlXSL File

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">	<xsl:for-each select="PRODUSE/PRODUS">	<tr onmouseover="this.style.background='#fe9'"onmouseout="this.style.background='#fff'">	  <td class="lCell"><xsl:value-of select="NrCrt"/></td>	  <td><xsl:value-of select="Denumire"/></td>						<td><xsl:value-of select="Reper"/></td>						<td><xsl:value-of select="Stocuri"/></td>						<td><xsl:value-of select="Pret"/></td>	</tr>	</xsl:for-each></xsl:template></xsl:stylesheet>

The XML File

<?xml version="1.0"?><PRODUSE>		<PRODUS>				<NrCrt>1</NrCrt>				<Denumire>Cuzinet biela 87790328</Denumire>				<Reper>N\A</Reper>				<Stocuri>5</Stocuri>				<Pret>106.32</Pret>				<Link>#</Link>		</PRODUS></PRODUSE>

And the code...

<script type="text/javascript">var isIE;var isNav;isIE = (navigator.appName == "Microsoft Internet Explorer");isNav = (navigator.appName == "Netscape");if (isIE){  // Load XML  var xml = new ActiveXObject("Microsoft.XMLDOM")  xml.async = false  xml.load("produse/Produse.xml")  // Load XSL  var xsl = new ActiveXObject("Microsoft.XMLDOM")  xsl.async = false  xsl.load("produse/Produse.xsl")  // Transform  document.write(xml.transformNode(xsl))}if (isNav){  //for mozilla/netscape  var processor = new XSLTProcessor();  var xslt = document.implementation.createDocument("", "", null);  xslt.async = false;  xslt.load("produse/Produse.xsl");  processor.importStylesheet(xslt);  var src_doc = document.implementation.createDocument("","", null);  src_doc.async = false;  src_doc.load("produse/Produse.xml");  var result = processor.transformToDocument(src_doc);  var xmls = new XMLSerializer();  var output = xmls.serializeToString(result);  document.write(output);}</script>

Link to comment
Share on other sites

Use this script to call the transformation. It's tested and it's known to work in Opera 9, FF 1.5, IE6 and IE7. Haven't tested FF2, but it should work there.If that doesn't work for you, then it's the fault of some other script you have running (god knows which one).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...