...

View Full Version : How to display the same XML file with different XSLT?



zhihaox
09-11-2002, 08: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-11-2002, 11:01 PM
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, 02:48 PM
Thanks, buddy! That's really what I want!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum