Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2015, 04:59 AM
Registered User
 
Join Date: Jul 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default JS loop in XSLT

Hi.
I'm use javascript in my xslt transforming and now i need use js loop like this:
Code:
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);
}
How I can set current counter value as index in <xsl:value-of select="Data/Row[CounterValueLikeIndex]/Count"/>

Thanks!

My xml:
Code:
<?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>
 
Old July 23rd, 2015, 06:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I think you're probably imagining that the XSLT code is executed once each time the JS loop is executed. Wrong! The XSLT code is executed while generating the HTML/JS page. By the time the Javascript executes, XSLT execution is all over and done with.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with XSLT variable into JS yankleber XSLT 10 January 22nd, 2015 07:08 AM
XSLT Loop? kwilliams XSLT 1 June 16th, 2008 06:04 PM
help to create dynamic listbox using xslt & JS kramsengg XSLT 7 June 10th, 2008 05:00 AM
FOR LOOP IN XSLT im_himanshu2004 XSLT 0 October 10th, 2007 02:27 PM
XSLT in IE: adding js object to a stylesheet Vx BOOK: Professional Ajax ISBN: 978-0-471-77778-6 2 August 22nd, 2006 11:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.