Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XSL-FO] Alternating Table Row Colors with an

Expand Messages
  • G. Ken Holman
    ... You are missing the principle that all attributes must be added to a result tree element before any of the content can be added. It would also seem you are
    Message 1 of 3 , May 26, 2003
      At 2003-05-24 22:42 +0000, raithnwno wrote:
      >displaying negative numbers in red text seem to be throwing
      >me for a loop. I have the code commented below <!-- highlight
      >negative growth in red --> but it doesnt seem to change the display
      >of those which are negative.
      >...
      ><xsl:template match="ProductLineID | Budget | DayBWSDollars
      >...
      > <td bordercolor="#000000" align="center"><xsl:value-of
      >select="."/>
      >
      > <!-- highlight negative growth in red -->
      ><xsl:if test="DayBWSDollars < 0">
      > <xsl:attribute name="style">
      > <xsl:text>color:red</xsl:text>
      > </xsl:attribute>
      ></xsl:if>
      > <!-- highlight negative growth in red -->

      You are missing the principle that all attributes must be added to a result
      tree element before any of the content can be added.

      It would also seem you are trying to test DayBWSDollars children of
      DayBWSDollars parents, which I'm guessing is not what you want to do ... I
      suspect you only want to add the color attribute if the current node being
      processed is DayBWSDollars.

      Perhaps try the following to address these two issues - note how the
      attribute is added to <td> before the content, and the test for the
      attribute is checking if the current node being processed is DayBWSDollars,
      not just checking for a child:

      <xsl:template match="ProductLineID | Budget | DayBWSDollars ...
      <td bordercolor="#000000" align="center">
      <xsl:if test="self::DayBWSDollars < 0">
      <xsl:attribute name="style">color:red</xsl:attribute>
      </xsl:if>
      <xsl:value-of select="."/>

      I hope this helps.

      .................. Ken

      --
      Upcoming hands-on courses: (registration still open!)
      - (XSLT/XPath and/or XSL-FO) North America: June 16-20, 2003

      G. Ken Holman mailto:gkholman@...
      Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
      Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
      ISBN 0-13-065196-6 Definitive XSLT and XPath
      ISBN 0-13-140374-5 Definitive XSL-FO
      ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
      ISBN 1-894049-11-X Practical Formatting Using XSL-FO
      Member of the XML Guild of Practitioners: http://XMLGuild.info
      Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
    Your message has been successfully submitted and would be delivered to recipients shortly.