Re: [xsl] javascript for loop inside xsl template

Subject: Re: [xsl] javascript for loop inside xsl template
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Fri, 03 May 2002 17:26:27 -0600
At 12:54 PM 5/3/2002, you wrote:
I was wondering if anybody could tell how to write a
javascript for loop inside an xsl template.


<xsl:template match="principle"> for (intIndex = 1; intIndex &lt; dependentObjectArray.length; intIndex++) { if ( dependentObjectArray[intIndex].value == intValue ) { dependentObjectArray[intIndex].disabled = true; } else { dependentObjectArray[intIndex].disabled = false; } } </xsl:template>

It's blowing up on &lt; in the for loop condition.

As Thomas pointed out, you can reverse the test to read
for (intIndex = 1; dependentObjectArray.length > intIndex; intIndex ++)
[JavaScript note: Do you mean to start at 1 or at 0?]
or you can write it the way you're comfortable and enclose the entire thing in a <![CDATA[ ]]> section.


<xsl:template match="principle">
  <![CDATA[
for (intIndex = 1; intIndex < dependentObjectArray.length; intIndex ++)
  {
  if (dependentObjectArray[intIndex].value == intValue)
    dependentObjectArray[intIndex].disabled = true;
  else
    dependentObjectArray[intIndex].disabled = false;
  }  // ends for
  ]]>
</xsl:template>



Greg Faron
Integre Technical Publishing Co.



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread