jose.rob.jr Posted January 10, 2007 Report Share Posted January 10, 2007 (edited) como eu faço pra saber se o número é par ou impar, para testar um valor e saber se um atributo é par ou impar com xsl?<table> <xsl:for-each select="asd/dsa/item"> <tr> <td> <xsl:if test="???????"> <xsl:attribute name="class">f2</xsl:attribute> </xsl:if> <p> <img src="i_folder.gif" alt="" /> <a><xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute><xsl:value-of select="title"/></a> <xsl:if test="description!=''"> (<xsl:value-of select="description"/>) </xsl:if> </p> </td> </tr> </xsl:for-each> </table> [edit] consegui assim: <table> <xsl:for-each select="asd/dsa/item"> <tr> <td> <xsl:if test="substring(@id, string-length(@id)) = '0' or substring(@id, string-length(@id)) = '2' or substring(@id, string-length(@id)) ='4' or substring(@id, string-length(@id)) ='6' or substring(@id, string-length(@id)) = '8'"> <xsl:attribute name="class">f2</xsl:attribute> </xsl:if> <p> <img src="i_folder.gif" alt="" /> <a><xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute><xsl:value-of select="title"/></a> <xsl:if test="description!=''"> (<xsl:value-of select="description"/>) </xsl:if> </p> </td> </tr> </xsl:for-each> </table>:) Edited January 10, 2007 by jose.rob.jr Quote Link to comment Share on other sites More sharing options...
0 Guest Osmar J. Silva Posted January 10, 2007 Report Share Posted January 10, 2007 Prezado,O teste para saber se um valor é par ou impar pode ser feito assim:<xsl:if test="valor mod 2 = 0">Se o resultado for 0 sabemos que o valor é parAbraçosOsmarDicas de Programação? Visite: http://www.recomende.com/arquivo/dicas_truques.php Quote Link to comment Share on other sites More sharing options...
Question
jose.rob.jr
como eu faço pra saber se o número é par ou impar, para testar um valor e saber se um atributo é par ou impar com xsl?
[edit] consegui assim::)
Edited by jose.rob.jrLink to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.