Subject: [xsl] Changing colors of eachother line From: Berger Dominik LE CH <dominik.berger@xxxxxxxxxx> Date: Tue, 14 Aug 2001 14:26:29 +0200 |
hi there i ve got a problem, i will make out of a xml-file a html-file with xsl. in the xml-file there are many fields, some of them have the value 'null'. i will display each second field with the same color in the html output. but i will not display the fields with the value 'null' so i cannot use the position() function. now can you tell me a way how i cann toggle the color-attribute for eachtime between two values?? i have here a example witch should show you what i'm looking for: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE page SYSTEM "C:\Program Files\Allaire\JRun\servers\default\test\portML.dtd"> <page> <object name="Detail" class="com.cibasc.infoport.Method"> <data> <row> <field no="0" name="Name" class="java.lang.String"> Berger </field> <field no="1" name="Firstname" class="java.lang.String"> null </field> <field no="2" name="Address" class="java.lang.String"> 45 Mainstreet </field> <field no="3" name="Phone" class="java.lang.String"> ++618992299222 </field> <field no="4" name="city" class="java.lang.String"> null </field> <field no="5" name="novalue" class="java.lang.String"> </field> <field no="6" name="test" class="java.lang.String"> test </field> </row> </data> </object> </page> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/object"> <HTML> <HEAD> </HEAD> <BODY class="st"> <xsl:apply-templates select="data"/> </BODY> </HTML> </xsl:template> <xsl:template match="data"> <table border="0" cellspacing="0" cellpadding="0"> <xsl:apply-templates select="row"/> </table> </xsl:template> <xsl:template match="row"> <xsl:apply-templates select="field"></xsl:apply-templates> </xsl:template> <xsl:template match="field"> <xsl:if test="normalize-space(.) != 'null' and normalize-space(.)!=''"> <tr> <td> <xsl:attribute name="width">180</xsl:attribute> <xsl:attribute name="valign">top</xsl:attribute> <xsl:attribute name="color"> <xsl:call-template name="getColor"> <xsl:with-param name="color" select="Blue"></xsl:with-param> </xsl:call-template> </xsl:attribute> <xsl:value-of select="@name"></xsl:value-of></td> <td> <xsl:attribute name="width">520</xsl:attribute> <xsl:attribute name="valign">top</xsl:attribute> <xsl:attribute name="color"> <xsl:call-template name="getColor"> <xsl:with-param name="color" select="Blue"></xsl:with-param> </xsl:call-template> </xsl:attribute> <xsl:value-of select="normalize-space(.)"></xsl:value-of></td> </tr> </xsl:if> </xsl:template> <xsl:template name="getColor"> <xsl:param name="color"/> <xsl:choose> <xsl:when test="$color = 'Blue'">Red</xsl:when> <xsl:otherwise>Blue</xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> The result should be something like this: <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="180" valign="top" color="Blue">Name</td> <td width="520" valign="top" color="Blue">Berger</td> </tr> <tr> <td width="180" valign="top" color="Red">Address</td> <td width="520" valign="top" color="Red">45 Mainstreet</td> </tr> <tr> <td width="180" valign="top" color="Blue">Phone</td> <td width="520" valign="top" color="Blue">++618992299222</td> </tr> <tr> <td width="180" valign="top" color="Red">test</td> <td width="520" valign="top" color="Red">test</td> </tr> </table> i hope you can help me, that would be great! thanks and best regards dominik berger XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Saxon message: bad contin, David_N_Bertoni | Thread | Re: [xsl] Changing colors of eachot, Rob Lugt |
Re: [xsl] Saxon message: bad contin, Aleksei Valikov | Date | RE: [xsl] working with XSLFO: valid, DPawson |
Month |