XSLT and Google chart tools

316 views
Skip to first unread message

Christopher Kimball

unread,
Feb 14, 2012, 7:31:19 PM2/14/12
to Google Visualization API
On Mac OSX 10.7.3 with Firefox 10.0, I'm having trouble getting Google
charts when the web page is a result of an XSL transformation.
Strangly, the files operate correctly on Safari and Opera, but not on
Firefox or Google Chrome.

Here are two files X.xml and X.xsl.xml. X.xml is a very simple file
consisting of a non-empty "X" tag and a reference to X.xsl.xml as its
XSL file for transformation.

X.xml:
<?xml version = "1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="X.xsl.xml"?>
<X>&#x00a0;</X>

X.xsl.xml is the XSL stylesheet. It responds only to the tag <x> and
outputs the HTML of one of the Google charts examples.

X.xsl.xml:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" >
<xsl:output method="html"/>
<xsl:template match="/X">
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn('number', 'Expenses');
data.addRows([
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 860, 580],
['2007', 1030, 540]
]);

var options = {
width: 400, height: 240,
title: 'Company Performance'
};

var chart = new
google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>
</xsl:template>
<!--
========================================================================--
>
</xsl:stylesheet>


Is there a problem in Javascript initialization?

Thanks,

Chris Kimball
Reply all
Reply to author
Forward
0 new messages