|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
||||
|
||||
|
Hello,
I'm trying to use XSL to display different color in each row of the table. But the method I used below does not work. Any idea? (In HTML) <TABLE> <TR BGCOLOR="#FFFFFF"><TD>1</TD> ... <TR> <TR BGCOLOR="#AAAAAA"><TD>2</TD> ... </TR> <TR BGCOLOR="#FFFFFF"><TD>3</TD> ... </TR> <TR BGCOLOR="#AAAAAA"><TD>4</TD> ...</TR> </TABLE> (In XSL) <TABLE> <xsl:for-each select="./Atts/Att"> <xsl:variable name="CHOOSE"><xsl:value-of select="position()"/></xsl:variable> <xsl:for-each select="./AttFormats/AttFormat"> <tr> <xsl:choose> <xsl:when test="$CHOOSE mod 2 = 0"> <xsl:attribute name="bgcolor">#FFFFFF</xsl:attribute> </xsl:when> <xsl therwise><xsl:attribute name="bgcolor">#AAAAAA</xsl:attribute> </xsl therwise></xsl:choose> <td><xsl:value-of select=".//somevalue"/></td> <td>...</td> </tr> </xsl:for-each> </xsl:for-each </TABLE> ================================= The variable $CHOOSE seems NOT work with the function 'mod'. more info: The XML look like <Atts> <Att> <something></something> <AttFormats> <AttFormat>jpg</AttFormat> <AttFormat>gif</AttFormat> </AttFormats> </Att> <Att> ... ... </Att> </Atts> I need to display each file format (Attformat) in one row inside a table. |
|
#2
|
|||
|
|||
|
XSL Help to sunnychan
I think you can try the following XSL stylesheet with your own XML document...
(you must put "bgcolor" attribute into "td" tag only...) <!-- ************************************* --> <?xml version='1.0' encoding='iso-8859-1' ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="yes" encoding="iso-8859-1" media-type="text/html"/><!-- ************************************* --> <xsl:template match="Atts"> <html> <head> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <!-- ************************************* --> <xsl:template match="Att"> <table> <xsl:apply-templates select="AttFormats"/> </table> </xsl:template> <!-- ************************************* --> <xsl:template match="AttFormats"> <xsl:for-each select="AttFormat"> <xsl:variable name="CHOOSE" select="position()"/> <tr> <xsl:choose> <xsl:when test="$CHOOSE mod 2 = 0"> <xsl:element name="td"> <xsl:attribute name="bgcolor">#FFFFFF</xsl:attribute> <xsl:value-of select="$CHOOSE"/> </xsl:element> </xsl:when> <xsl therwise><xsl:element name="td"> <xsl:attribute name="bgcolor">#AAAAAA</xsl:attribute> <xsl:value-of select="$CHOOSE"/> </xsl:element> </xsl therwise></xsl:choose> </tr> </xsl:for-each> </xsl:template> <!-- ************************************* --> </xsl:stylesheet> i hope it will work fine as you want Regards Analogx (don't hesitate to contact me if you need some help...) |
|
#3
|
|||
|
|||
|
It's not the choose...
We're using xalan (Java) to do XSLT. What we found out is that you can only set a xsl:variable ONCE. So when it's set once, it keeps that value. We work around it by determining the value elsewhere and passing it in through xsl
aram |
|
#4
|
|||
|
|||
|
Hello
I don't know Xalan. i'm using Sablotron with PHP. Sablotron is a XSLT Processor written in C++ (i think it's greter than Java :-)) ). For more informations i invite you to see Sablotron homepage URL Regards analogx |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|