开发者

two adjacent tables in body-region each with two columns(xsl-fo)

the xml document

<?xml version="1.0" encoding="ISO-8859-1" ?>
&l开发者_开发问答t;NVELOPE>
    <PAYSTITLE>No. of Days</PAYSTITLE>
    <PAYSVALUE>8 Days</PAYSVALUE>
    <ETITLE>Basic Pay - Project</ETITLE>
    <EAMT>-45.00</EAMT>
    <ETITLE>House Rent</ETITLE>
    <EAMT>-08.00</EAMT>
    <ETITLE>Transport</ETITLE>
    <EAMT>-18.00</EAMT>
    <ETITLE>Special</ETITLE>
    <EAMT>-15.00</EAMT>
    <ETITLE>Variable Pay</ETITLE>
    <EAMT>-15.00</EAMT>
    <ETITLE>Bonus</ETITLE>
    <EAMT>-8.00</EAMT>
    <DTITLE>M D S</DTITLE>
    <DAMT>50.00</DAMT>
    <DTITLE>Fund</DTITLE>
    <DAMT>95.00</DAMT>
    <DTITLE>Tax</DTITLE>
    <DAMT>25.00</DAMT>
</NVELOPE>

I NEED THIS DATA IN PDF FORMAT USING XSLT AND XSL-FO

i want data to be parallelly distributed in both the adjacent tables.

i basically donno how to get two adjacent tables or u can use a single table with four columns but i cant distribute data properly...

title    amt     title     amt
title    amt     title     amt
title    amt     title     amt
title    amt     title     amt
title    amt     title     amt

this is the way i want.... plz help me thanks in advance... :)


You can accomplish this by using a two column table that contains the tables you would like side-by-side in a single row.

<fo:table>
    <fo:table-column column-number="1"/>
    <fo:table-column column-number="2"/>
    <fo:table-body>
        <fo:table-row>
            <fo:table-cell>
                <fo:block>
                    <TABLE 1 HERE>
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
        <fo:table-row>
            <fo:table-cell>
                <fo:block>
                    <TABLE 2 HERE>
                </fo:block>
            </fo:table-cell>
        </fo:table-row>
    </fo:table-body>

With the tables in place you can use xsl:if + position() to limit the data that populates the sub-tables.


Process the elements in groups of four:

  <xsl:template match="NVELOPE">
    <fo:table>
      <fo:table-body>
        <xsl:call-template name="row" />
      </fo:table-body>
    </fo:table>
  </xsl:template>

  <xsl:template name="row">
    <xsl:param name="cells" select="*" />

    <fo:table-row>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[1]" /></fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[2]" /></fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[3]" /></fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block><xsl:apply-templates select="$cells[4]" /></fo:block>
      </fo:table-cell>
    </fo:table-row>
    <xsl:if test="count($cells) > 4">
      <xsl:call-template name="row">
        <xsl:with-param name="cells" select="$cells[position() > 4]" />
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

If the number of elements isn't a multiple of four, this will produce fo:table-cell containing an empty fo:block for the remainder of the row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜