2011-03-15 26 views
1

xml文檔兩個相鄰表中的身體區域中的每個具有兩列(XSL-FO)

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<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> 

我需要這個DATA IN PDF格式中使用XSLT和XSL-FO

我想數據到並行分佈在兩個相鄰的表中。

我基本上唐諾如何讓兩個相鄰的表或U可以使用一個表有四列,但我不能合理分配數據...

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

這是我所希望的方式.... PLZ請幫助我在此先感謝... :)

+0

答案完全取決於XSL-FO詞彙表:如果您可以表達兩列布局,那麼不需要更多的流程。如果你不能,那麼你需要XSLT構建的**一個**表(如EXCEL電子表格)。 – 2011-03-15 14:30:02

回答

2

您可以通過使用包含您想在一行中並排放置的表的兩列表來實現此目的。

<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> 

通過使用表格,您可以使用xsl:if + position()來限制填充子表的數據。

+0

在父節點(NVELOPE)中得到了不同的節點..所以我沒有找到一種方法來輸出PDF中的所有這些數據... 即時通訊xsl中的noob xslfo ... plz幫助我... 非常感謝... :) – 2011-04-04 07:26:27

0

過程中的四組的元素:

<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> 

如果元件的數目不是四的倍數,這將產生包含所行的其餘部分的空fo:blockfo:table-cell

相關問題