If $HowMany is a positive number, not($HowMany) will return false(), which is converted to 0 (zero) for use in the multiplication. 0 times 9999 is 0, so we end up comparing position() to the number iin $HowMany.
If, however, $HowMany is zero, not($HowMany) returns true(), which is converted to 1 - one times 9999 is 9999, which the current position() will likely be less than - so there you have it.
You just ned to make sure that 9999 is "big enough" in your context.
Change variable value to count if it is 0
Hi,
I have the following code:
<xsl:variable name="HowMany" select="/macro/HowMany" />
<xsl:template match="/">
<xsl:for-each select="$currentPage/child::*/broker [@isDoc][position() <= $HowMany]">
I want to set it up so that if HowMany is zero, the for-each will run for all positions.
How can I do this?
Thank you!
Hi Elad,
You can use a little programmer trick:
If $HowMany is a positive number, not($HowMany) will return false(), which is converted to 0 (zero) for use in the multiplication. 0 times 9999 is 0, so we end up comparing position() to the number iin $HowMany.
If, however, $HowMany is zero, not($HowMany) returns true(), which is converted to 1 - one times 9999 is 9999, which the current position() will likely be less than - so there you have it.
You just ned to make sure that 9999 is "big enough" in your context.
/Chriztian
Nice!
Thank you!
is working on a reply...