Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
28
rated 0 times [  34] [ 6]  / answers: 1 / hits: 51636  / 13 Years ago, tue, april 19, 2011, 12:00:00

I want to use JavaScript to show my XSLT, but on my server nothing is showing up in the browser.



<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<html>
<head>
<script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js></script>
<script type=text/javascript src=main.js></script>
<meta http-equiv=Content-Language content=en-us/>
<title>Contracting, Licensing and Compliance News</title>
</head>
<body>
<script language=javascript>
function displayMessage() {
// Load XML

var xml = new ActiveXObject(Microsoft.XMLDOM)
xml.async = false
xml.load(site-index.xml)

// Load the XSL
var xsl = new ActiveXObject(Microsoft.XMLDOM)
xsl.async = false
xsl.load(site-index.xsl)

// Transform
document.write(xml.transformNode(xsl))
}
</script>
</body>
</html>

More From » xml

 Answers
4

The browser can perform the tranform for you. No javascript is needed, just link the .xsl from the .xml like this:



<?xml version=1.0 encoding=UTF-8?>
<?xml-stylesheet type=text/xsl href=site-index.xsl ?>


and just serve the xml, no html. Assuming your .xsl contains the right code, along the lines



<xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform>
<xsl:output method=html version=4.01 indent=yes/>
<xsl:output doctype-system=http://www.w3.org/TR/html4/strict.dtd/>
<xsl:output doctype-public=-//W3C//DTD HTML 4.01//EN/>

[#92645] Monday, April 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mireyag

Total Points: 73
Total Questions: 107
Total Answers: 85

Location: Ukraine
Member since Sun, Dec 13, 2020
3 Years ago
mireyag questions
Sun, Aug 15, 21, 00:00, 3 Years ago
Wed, Dec 16, 20, 00:00, 3 Years ago
Tue, Sep 1, 20, 00:00, 4 Years ago
Sun, Jul 5, 20, 00:00, 4 Years ago
;