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

RE: [XSL-FO] Table: Alternating background color

Expand Messages
  • vijay chiniwar
    Hi I used this, and i get alternate colours,
    Message 1 of 5 , Jan 6, 2006

      I used this, and i get alternate colours,

      <xsl:for-each select="/screening/company-ticker">
      <xsl:choose >
      <xsl:when test="position() mod 2 = 0">
      <fo:table-row background-color="grey" >
      <xsl:otherwise >
      <fo:table-row background-color="white">

      </xsl:choose >

      Stephen Siu <ssiu@...> wrote:
      Hi Ken,

      Thanks for responding.

      Sorry I did not include more information. The inputs into my
      simple-tables are


      I was not particularly sure what you meant but I put the following in my

      <xsl:template match="strow">
      <xsl:apply-templates select="stentry"/>
      <xsl:variable name="row-pos" select="position()"/>
      <xsl:attribute name="background-color">
      <xsl:when test="$row-pos mod 2">blue</xsl:when>

      Because I noticed earlier in my XSLT that I performed conditionality
      tests using "choose". However, this code produces an error which I
      cannot debug.

      I was generally unsure how you set up the markup in your explanation.
      Thanks for your help :)

      -----Original Message-----
      From: XSL-FO@yahoogroups.com [mailto:XSL-FO@yahoogroups.com] On Behalf
      Of G. Ken Holman
      Sent: December 21, 2005 3:21 PM
      To: XSL-FO@yahoogroups.com
      Subject: Re: [XSL-FO] Table: Alternating background color

      At 2005-12-21 14:46 -0500, Stephen Siu wrote:
      >I was wondering - how would I go about having alternating background
      >colors for each row? For example the first row would be dark gray, next
      >would be light, etc.

      Generally when using XSLT to produce the XSL-FO one would
      algorithmically test the parity of the row number at the point of
      creating the table-cell or table-cell contents and set the background

      You don't give any example input XML vocabulary, so consider that you
      have input as:


      In your XSLT you match on rows and process each row:

      <xsl:template match="rows">
      <xsl:apply-templates select="row"/>

      The handling of the row then has the current row in the position in
      the current node list created by selecting all rows; below I put it
      in a variable because I'm guessing the current node will change in
      the processing of the row contents:

      <xsl:template match="row">
      <xsl:variable name="row-pos" select="position()"/>
      <!--assume background colour-->
      <xsl:attribute name="background-color">white</xsl:attribute>
      <xsl:if test="$row-pos mod 2">
      <xsl:attribute name="background-color">gray</xsl:attribute>

      The above could be accomplished with many other possible constructs
      based on how you choose to process your XML, but that's the gist. In
      the above I just first assume that the colour is white, then if the
      parity of the row number is odd I change it to gray.

      I hope this helps.

      . . . . . . . . . . Ken

      Upcoming XSLT/XSL-FO hands-on courses: Denver,CO March 13-17,2006
      World-wide on-site corporate, govt. & user group XML/XSL training.
      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)
      Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/f/bc
      Legal business disclaimers: http://www.CraneSoftwrights.com/legal

      Yahoo! Groups Links

      This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

      Xml xsl Xsl Xsl fo Xsl-fo Xsl tutorial


      Visit your group "XSL-FO" on the web.

      To unsubscribe from this group, send an email to:

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      Yahoo! DSL Something to write home about. Just $16.99/mo. or less

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.