position(): Simplifying when possible

9 views
Skip to first unread message

Thomas Lehmann

unread,
Oct 6, 2011, 8:47:00 AM10/6/11
to xs...@googlegroups.com
Hi,

is it possible to write last loop as one value-of statement?

[code]
                <!-- assume the 1st day in a month is monday: what day is the 15th? -->
                The 15th day is: <xsl:value-of select="str:tokenize($day-names, '|')[15 mod 7]"/><br/>
                <!-- assume the 1st day in a month is monday: what day is the 26th? -->
                The 26th day is: <xsl:value-of select="str:tokenize($day-names, '|')[26 mod 7]"/>
                <hr/>
                <!-- what position is wednesday? -->
                <xsl:for-each select="str:tokenize($day-names, '|')">
                    <xsl:if test=". = 'Wed'">
                        <xsl:value-of select="position()"/>
                    </xsl:if>
                </xsl:for-each>
[/code]

Thomas Lehmann

unread,
Oct 6, 2011, 9:13:08 AM10/6/11
to xs...@googlegroups.com
I found the answer;

[code]

                <!-- what position is wednesday? -->
                <xsl:value-of select="count(str:tokenize($day-names, '|')[.='Wed']/preceding-sibling::*)+1"/>
[/code]

Help from here: http://stackoverflow.com/questions/226405/find-position-of-a-node-using-xpath

Reply all
Reply to author
Forward
0 new messages