1
votes

This is my following xslt code :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output encoding="iso-8859-1" />
<xsl:template match ="records">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
            <fo:simple-page-master master-name="list">
                <fo:region-body></fo:region-body>
            </fo:simple-page-master>
        </fo:layout-master-set>

        <fo:page-sequence master-reference="list">
            <fo:flow flow-name="xsl-region-body">
                <fo:block>
                    <fo:table>
                        <fo:table-body>

                             <xsl:for-each select="./list">
                                <fo:table-row>
                                     <xsl:for-each select="./item">
                                    <fo:table-cell border="solid 1px bold" text-align="center"  backgr="green">
                                        <fo:block><xsl:value-of select="val" /></fo:block>
                                    </fo:table-cell>
                                    </xsl:for-each>


                                </fo:table-row>
                            </xsl:for-each>
                        </fo:table-body>
                    </fo:table>
                </fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>
</xsl:stylesheet>

i am trying to add backgorund table-cell,but it is not working. In foLtable-cell i have added backgr attribute, but it didnot worked.

3

3 Answers

1
votes

The correct attribute for defining an background color is "background", but you used "backgr" instead. I tried the corrected code and it works as expected (using the Altsoft Xml2PDF Renderer).

0
votes

It must be like

 <fo:table-cell border="solid 1px bold" text-align="center"  
                                            background-color="green">

See also :XSL-FO table-cell Object

0
votes

You can use the background-color attribute on a table-row or table-header element.

<fo:table-header background-color="#555">

or

<fo:table-row background-color="#555">