Helpful Information
 
 
Category: XML
How to display the same XML file with different XSLT?

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?

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

Thanks, buddy! That's really what I want!










privacy (GDPR)