View Full Version : How to display the same XML file with different XSLT?
zhihaox
09-11-2002, 09:05 PM
I have an XML file acting as a dictionary in a bilingual website. But for a certain XML file, you can only specify an XSLT to express it. How do I display the XML file with different XSLTs?
kathryngz
09-12-2002, 12:01 AM
If you're using IE, you can remove the XSL reference from your XML document and use the following javascript (changing the names of the XML and XSL to your filenames).
<script type="text/javascript">
// Load XML
var xml = new ActiveXObject("MSXML2.DOMDocument")
xml.async = false
xml.load("yourfile.xml")
// Load the XSL
var xsl = new ActiveXObject("MSXML2.DOMDocument")
xsl.async = false
xsl.load("file1.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
To apply another stylesheet, just duplicate the code in a different document and specify a different XSL file.
HTH--
Kathryn
zhihaox
09-12-2002, 03:48 PM
Thanks, buddy! That's really what I want!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.