Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

JS loop with xsl variable

$
0
0

Hi! I having one XML file having a structure like this:

<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="temp.xslt" ?><Data><Row><DateAndTime>2015-07-03</DateAndTime><Count>406</Count><Count2>638</Count2></Row><Row><DateAndTime>2015-07-04/DateAndTime><Count>697</Count><Count2>697</Count2></Row></Data>

And for transform using xslt file (temp.xslt) with include javascript like this:

<?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" version="1.0" encoding="utf-8" indent="yes"/><xsl:template match="/"><html><head><script type="text/javascript"> function showTest() { var rowCount = <xsl:value-of select="count(Data/Row)" /> for(var i = 0; i &lt; rowCount; i++) {<xsl:variable name="nValue">i</xsl:variable> var s1 = <xsl:value-of select="$nValue" /> var passcount = <xsl:value-of select="Data/Row[$nValue]/Count"/>; alert(passcount); } }</script></head><body><input type="button" value="view" onclick="showTest()" /></body></html></xsl:template></xsl:stylesheet>


How I can set index (ex. i in js loop) for <xsl:value-of select="Data/Row[INDEX]/Count"/>.

I tried to use <xsl:value-of select="Data/Row[i]/Count"/> but it's no work.
Any ideas?
Thanks!



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>