This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: javascript for loop inside xsl template


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]