For some reason position() did not work. But, thanks to you Matt, i finally
got things to work the way I wanted. For anybody else interested in the same
solution here is a segment of my XSL-

  <xsl:template match="record">
        <xsl:variable name="pos">       
                <xsl:number level="any" from="report"/>
        </xsl:variable>
        <fo:table>
                <xsl:attribute name="background-color">
                        <xsl:choose>
                                <xsl:when test="$pos mod 2 =
'0'">white</xsl:when>
                                <xsl:otherwise>grey</xsl:otherwise>
                        </xsl:choose>
                </xsl:attribute>

                <fo:table-column column-width="20mm"/>
                <fo:table-column column-width="20mm"/>

thanks
-Srinivas

-----Original Message-----
From: Savino, Matt C [mailto:[EMAIL PROTECTED]
Sent: Monday, February 18, 2002 6:01 PM
To: '[EMAIL PROTECTED]'
Subject: RE: setting a property with value of a variable


If you need to use a variable instead of an attribute, try this (don't
forget the '$'):

   <fo:table background-color="{$bakColor}" />


Or if you need the attribute to be the result of something more complicated
like a choose statement, you can use <xsl:attribute>:

<fo:table>
  <xsl:attribute name="background-color">
    <xsl:choose>
      <xsl:when test="position() mod 2 = '1'">white</xsl:when>
      <xsl:otherwise>grey</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>


good luck,
Matt

> -----Original Message-----
> From: Sampige, Srinivas [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 18, 2002 5:41 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: setting a property with value of a variable
> 
> 
> Okay ,found the answer
>       <fo:table background-color="@bakColor">
> 
> -Srinivas
> 
> -----Original Message-----
> From: Sampige, Srinivas [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 18, 2002 5:35 PM
> To: FOPuser (E-mail)
> Subject: setting a property with value of a variable
> 
> 
> Hi
>  I want a set of tables with alternating background colours. 
> To do this I
> intend to set the background of the table with the value of a 
> variable which
> will contain "white" or "grey". How do I do that?. Presently my .XSL
> contains this -
> 
>   <xsl:template match="record">
> 
>       <xsl:variable name="bakColor" select="yellow"/>
>       <fo:table background-color='<xsl:value-of select="bakColor"/>\'>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/>
>               <fo:table-column column-width="20mm"/> 
> 
>               <fo:table-body>
>                       <xsl:apply-templates/>
>               </fo:table-body>
>       </fo:table>
>   </xsl:template>
> 
>  But I am getting this error when I try to apply it to my XML file -
> --------------------------------------------------------------
> --------------
> --------------------------------------------------------------
> --------------
> -----------------
> C:\Apps\Apache Group\xalan-j_1_2_2\samples\SimpleTransform>java
> SimpleTransform
> file:///C:/Apps/Apache
> Group/xalan-j_1_2_2/samples/SimpleTransform/jeffReport.xsl; 
> Line 71; Column
>  31
> XSL Error: Could not parse jeffReport.xsl document!
> XSL Error: SAX Exception
> Exception in thread "main" 
> org.apache.xalan.xslt.XSLProcessorException: The
> value of attribute "ba
> ckground-color" must not contain the '<' character.
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1753)
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.processStylesheet(XSLTEng
> ineImpl.java:8
> 13)
>         at
> org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:647)
>         at SimpleTransform.main(SimpleTransform.java:81) 
> --------------------------------------------------------------
> --------------
> --------------------------------------------------------------
> --------------
> -------------
> 
> can sombody please help?
> 
> thanks
> Srinivas
> 

Reply via email to