Question

The Example

I'm trying to generate a table, where columns are added or removed dynamically, depeindig on user input. Problem is, that the empty columns are still visible (see the Picture)

My current approach is using xsl:if. (see the code snippet)

<fo:table table-layout="fixed" width="100%" font-family="Helvetica" font-size="12pt">
                        <fo:table-body start-indent="5pt">
                            <fo:table-row>
                                <fo:table-cell>
                                    <fo:block>
                                    <xsl:if test="boolean(./targetAgreements/targetAgreement/area/@visible = 'true')">
                                        Area
                                        </xsl:if>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell>
                                    <fo:block>
                                    <xsl:if test="boolean(./targetAgreements/targetAgreement/brand/@visible = 'true')">
                                        Brand
                                        </xsl:if>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell>
                                    <fo:block>
                                     <xsl:if test="boolean(./targetAgreements/targetAgreement/currentTarget/@visible = 'true')">
                                        Current Target
                                        </xsl:if>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell>
...

If I try to surround the table-cell with the xsl:if it tells me, that table-row requires at least one table-cell as a child element.

How can I remove the empty columns completely?

Thanks!!

Was it helpful?

Solution

I did some kind of workaround...

The first table-cell is always there (without the xsl:if). The following cells are surrounded with the xsl:if.

See an example:

<fo:table table-layout="fixed" width="100%" font-family="Helvetica" font-size="12pt">
      <fo:table-header >
           <fo:table-row font-weight="bold" background-color="rgb(133,133,133)">
                <fo:table-cell>
                    <fo:block>
                        <xsl:value-of select="./headlines/headline[1]" />
                    </fo:block>
                </fo:table-cell>
                <xsl:if test="boolean(./targetAgreements/targetAgreement/brand/@visible = 'true')">
                    <fo:table-cell>
                        <fo:block>
                            <xsl:value-of select="./headlines/headline[2]" />
                        </fo:block>
                    </fo:table-cell>
                </xsl:if>
                <xsl:if test="boolean(./targetAgreements/targetAgreement/currentTarget/@visible = 'true')">
                    <fo:table-cell>
                        <fo:block>
                            <xsl:value-of select="./headlines/headline[3]" />
                        </fo:block>
                     </fo:table-cell>
                </xsl:if>
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top