2011-05-25 92 views
1

我是XSL FO的初學者。 我有一個非常簡單的XML文檔:在XSL FO文檔中寫入XSL-t

<?xml version= "1.0" ?> 
<test> 
TEST 
</test> 

我想打印的標籤<test>

我寫了下面XLS FO文檔由FOP處理的內容。

<fo:root xmlns:yt="http://www.yseop.com/text/2" 
xmlns:y="http://www.yseop.com/engine/3" 
xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 


    <fo:layout-master-set> 
     <fo:simple-page-master master-name="rapport"> 
     <fo:region-body margin-top="0.75in" margin-left="0.75in" margin-right="0.75in" margin-bottom="0.75in"/> 
     <fo:region-after extent="0.25in"/> 
     <fo:region-start/> 
     </fo:simple-page-master> 
    </fo:layout-master-set> 

    <fo:page-sequence master-reference="rapport"> 

     <fo:flow flow-name="xsl-region-body"> 
      <fo:block> 
      XXX 
       <xsl:apply-templates select="document('D:\XXX-conseilVente\xmlBatch\input_test1.xml')/test"/> 
      </fo:block> 
     </fo:flow> 
    </fo:page-sequence> 



</fo:root> 

我得到以下警告:

 [fop] 25 mai 2011 12:05:10 org.apache.fop.events.LoggingEventListener processEvent 
     [fop] ATTENTION: Unknown formatting object "{http://www.w3.org/1999/XSL/Transform}apply-templates" encountered (a child of fo:block}. (See position 22:99) 

並沒有什麼對我的輸出PDF。

我想我沒有使用正確的函數解析使用XSL-T文檔

你能告訴我用什麼功能?

在此先感謝

回答

4

XSLT和XSL-FO是兩種不同的語言。基本上,它的運行方式與目前的做法相比:FO嵌入在XSLT樣式表中,然後用於處理原始XML以創建XSL-FO文檔(不含任何XSLT)。這被扔在XSL-FO處理器上以創建例如PDF。

XSLT  processing 
    |   | 
XML ---> XSL-FO ---> PDF 

所以,你開始用XSLT樣式表是這樣的(沒有命名空間和這樣的,只是給你一個想法):

<xslt:stylesheet> 

    <xslt:template match="/"> 
    <fo:root> 
     <!-- fo head --> 
     <fo:page-sequence> 
     <fo:flow> 
      <xslt:apply-templates /> <!-- process the rest of the doc--> 
     </fo:flow> 
     </fo:page-sequence> 
    </fo:root> 
    </xslt:template> 

    <xslt:template match="test"> 
    <fo:block> 
     <xslt:value-of select="." /> 
    </fo:block> 
    </xslt:template> 

</xslt:stylesheet> 

你可以找到Dave Pawson's XSL FAQ ansered許多問題。

+0

非常感謝,它完美的作品。 – 2011-05-25 15:31:17

+0

不客氣。 – Boldewyn 2011-05-25 17:48:50