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