<xsl:if test="position() mod 3 = 0 | position() = 1"> doesn't work...

<xsl:if test="position() mod 3 = 0 | position() = 1"> doesn't work...

Post by Gabriel_ » Sat, 05 Jul 2003 04:25:50



...doesn't work, so how can I express this? parser says it's not a node
set...?

/Gabriel

 
 
 

<xsl:if test="position() mod 3 = 0 | position() = 1"> doesn't work...

Post by Dimitre Novatche » Sat, 05 Jul 2003 05:18:05


"|" is the union operator, which is defined on node-sets.

Use the boolean "or" operator.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


Quote:> ...doesn't work, so how can I express this? parser says it's not a node
> set...?

> /Gabriel


 
 
 

<xsl:if test="position() mod 3 = 0 | position() = 1"> doesn't work...

Post by Gabriel_ » Sat, 05 Jul 2003 05:13:54


Ah of course.. thanks a bunch :)

/Gabriel



> "|" is the union operator, which is defined on node-sets.

> Use the boolean "or" operator.

> =====
> Cheers,

> Dimitre Novatchev.
> http://fxsl.sourceforge.net/ -- the home of FXSL



> > ...doesn't work, so how can I express this? parser says it's not a node
> > set...?

> > /Gabriel

 
 
 

1. <xsl:if test="position() mod 2 = 0"> not working.

Hello,

In my XSL code I have the following:

<xsl:for-each select="NODE1/NODE2/NODE3">
        <xsl:if test="position() mod 2 = 0">
                <div>
                        <xsl:attribute name="id"><xsl:value-of select="position()
mod 2" />
                        </xsl:attribute>
                </div>
        </xsl:if>

        ...some more code...

</xsl:for-each>

I expect this only to include a div in the output of every other loop. However,
what I get is <div id="1"></div> in the first loop, followed by <div
id="0"></div> in the next, followed by <div id="1"></div> in the next and so on.
Even though the test is "position() mod 2 = 0" (returning true on the second,
forth, sixth etc. loops, i.e. 2 mod 2 = 0 and 4 mod 2 = 0 etc.), what I see is a
div in every loop, no matter whether the test is satisified. When I noticed this
problem, I added the <xsl:value-of select="position() mod 2" /> to check the
result of the test. I do not understand why I am seeing <div id="1"></div>. The
id of the div is the result of the test, which should only be true when the
result is 0 and therefore only be output when the result is 0.
Can anyone shed any light on what is happening here?

Sean.

2. Help With IPXSend / segments

3. Whats wrong with this <xsl:when test="@order='1'">

4. Platinum dumb! HELP!!

5. <a href="<xsl:value-of select="FI"/>"> ????

6. centrally managed Win95 off Netware 3.12

7. "<", ">","[","]" As XML Element Values ???

8. DS1100 drives cause errors when bootup O2

9. Printing special characters, "&", "<", and ">"

10. Sorting and Paging Woes using "SelectNodes" and "Position()"

11. Using <xsl:variable name="alt" select="position() mod 2"/> causing parse error

12. <name value="joe"/> vs. <name>joe</name>

13. XSLT: "do this <xsl:value-of select="."/> times"