<script type="text/javascript"> myarray = [ <xsl:for-each select="myitems/items">"<xsl:value-of select="item" />"<xsl:if test="position()!=last()">,</xsl:if></xsl:for-each> ]; </script>