This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Javascript looping expression in stylesheet
- From: "Zoe Peng" <zoe at allfools dot net>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 8 May 2002 14:22:23 -0400
- Subject: [xsl] Javascript looping expression in stylesheet
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
I am going to include a javascript inside the stylesheet. It works in
some javascripts. But, it fails when I try to use for function.
some charactures can't escape such as for (var i = 1; i <= nom; i++) {}
It fails in = sign or & sign. any ideas? Thanks.
--Zoe
<!-- xsl file -->
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="java redirect"
xmlns:java="http://xml.apache.org/xslt/java">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<!-- load the javascript file -->
<script language="JavaScript1.2">
<xsl:comment>
<xsl:call-template name="js" />
<xsl:text> // </xsl:text>
</xsl:comment>
</script>
</head>
<body>
...
</body>
</html>
</xsl:template>
<xsl:template name="js">
<xsl:text>
var nom = 4; // Number of menus
var usePictures = 1; // use pictures? 1 = yes, 0 = no
var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;
if (document.layers) {
visible = 'show';
hidden = 'hide';
}
else
if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
<!-- ### fail #### -->
for (var i = 1; i <= nom; i++) {
ttls[i] = ('title' + i);
subs[i] = ('submenu' +i);
}
..........
</xsl:text>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list