Jump to content

Javascript Transforming XML to XHTML - Fails in Safari Only


Dozzer81

Recommended Posts

Posted

I'm having an issue with using javascript to transform xml to xhtml, it works fine in IE7,IE6,IE5.5,IE5, Firefox,Opera but not in Safari 2 or 3. I have gone to numerous sites and forums but there doesn't seem to be a way to get it to work. I'm not using server side as I have had too many problems trying to implement this. I would have thought that Safari would have had no problems with this but I have been mistaken.Here is an example of the XML,XSLT and XHTML.XML:

<?xml version="1.0" encoding="ISO-8859-1"?><artistlist><artist><name>Alexander Akilov</name><address>akilov_a.html</address></artist><artist><name>Tom Piaskowski</name><address>piaskowski_t.html</address></artist><artist><name>Yuri Negadaev</name><address>negadaev_y.html</address></artist></artistlist>

XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><html>	<head>		<title>Solana Gallery - Contemporary russian art</title>		<link href="gallery.css" rel="stylesheet" type="text/css" />		<script type="text/javascript" src="nav.js"></script>	</head>	  <body>		<div class="logo"><a href="index.html"><img src="images/Small_Solana-Logo.png" alt="Solana Gallery Logo" /></a></div>		<div class="container">			  <h2>Artist List</h2>			  <ul class="clientlist">				<xsl:for-each select="artistlist/artist">				  <li>				<a href="{address}"><p><xsl:value-of select="name"/></p></a></li>				</xsl:for-each>			  </ul>		</div><ul id="nav">	<li><a href="index.html">Home</a></li>	<li><a href="artistlist.html">Artists</a></li>	<li><a>Exhibitions</a>		<ul>			<li><a href="recent.html">Recent</a></li>			<li><a href="future.html">Future</a></li>			<li><a href="past.html">Past</a></li>		</ul>	</li>	<li><a href="contactus.html">Contact Us</a></li>	<li><a>About Us</a>		<ul>			<li><a href="whoweare.html">Who We Are</a></li>			<li><a href="artservices.html">Art Services</a></li>			<li><a href="clients.html">Clients</a></li>			<li><a href="news.html">News</a></li>		</ul>				</li>	</ul><!-- end the menuh div -->	  </body>  </html>	</xsl:template>  </xsl:stylesheet>

XHTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Solana Gallery - Contemporary russian art</title><script type="text/javascript">var xmlDoc;{// code for IEif (window.ActiveXObject)  {  // Load XML  var xml = new ActiveXObject("Microsoft.XMLDOM");  xml.async=false;  xml.load("artistlist.xml");  // Load XSL	var xsl = new ActiveXObject("Microsoft.XMLDOM");	xsl.async = false;	xsl.load("artistlist.xsl");	// Transform	document.write(xml.transformNode(xsl))  }// code for Mozilla, Firefox, Opera, etc.else if (document.implementation && document.implementation.createDocument)  {  xmlDoc=document.implementation.createDocument("","",null);  xmlDoc.async=false;  xmlDoc.load("artistlist.xml");  var xsltProc = new XSLTProcessor();  var xsl=document.implementation.createDocument("","",null);  xsl.async=false;  xsl.load("artistlist.xsl");  xsltProc.importStylesheet(xsl);  xmlDoc=xsltProc.transformToDocument(xmlDoc);  var serializer=new XMLSerializer();  document.write(serializer.serializeToString(xmlDoc));  }else  {  alert('Your browser cannot handle this script');  }}</script></head><body></body></html>

I would appreciate any help with this as I have never really used Javascript before and have only begun with XMl and XSLT. Thank you.

Posted

Try the JavaScript from this topic. I just tested it on Safari 3/Windows, and there isn't any problem. At least not with the XML and XSLT I have anyway. I haven't tried yours, but if they work everywhere else, there shouldn't be any problems.

Archived

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

×
×
  • Create New...