Hello experts!
I've recently run into a problem regarding the use xml+xslt+javascript
in Firefox. The problem is that I'm loading an XML document with a
XSLT stylesheet
that has embedded javascript. I use the javascript for formatting
date-
times (see http://blog.stevenlevithan.com/archi...te-format-1-0).
The date.format.js library is included in the 'head' section of the
document. I also create a function to transform a unix timestamp
string (from the xml) into something human readable. So the top of my
stylesheet looks as follows:
<xsl:template match='/'>
<html>
<head>
<script type='text/javascript' src='/ui/date.format.js'></script>
<script type='text/javascript'>
function unix2human(unix) {
var date = new Date(unix * 1000);
return dateFormat(date, 'dddd, mmmm d, yyyy');
}
</script>
</head>
.....
And here is the section where unix2human is called:
<a href='somelink'>
<script>
document.write(unix2human(<xsl:value-of select='normalize-space(.)'/
>));</script>
</a>
Examining the error console I find that that unix2human is not defined
(but it is!). Doubly frustrating is that this code works as intended
in Safari --- i.e. the dates are converted from a unix timestamp to
the correct format. Any thoughts?
Anton