2016-11-08 105 views
0

我將Java代碼中的幾個參數傳入我的XSL樣式表中,用於使用XSL生成PDF:FO,但出現此錯誤:XSLT:XTSE0010:一個fo:block元素不能包含一個xsl:param元素

XTSE0010: An fo:block element must not contain an xsl:param element 

這是我的樣式表(部分):

<fo:flow flow-name="xsl-region-body"> 
    <fo:block> 
     <xsl:value-of select="reportContent/client/clientId"/> 
    </fo:block> 
    <fo:block font-weight="bold"> 
     <xsl:value-of select="reportContent/client/clientName" /> 
    </fo:block> 
    <fo:block> 
     <xsl:value-of select="reportContent/client/clientAddress" /> 
     ,<xsl:value-of select="reportContent/client/clientTown" /> 
    </fo:block> 
    <fo:block> 
     <xsl:value-of select="reportContent/reportInterval/startDate"/> 
     - <xsl:value-of select="reportContent/reportInterval/endDate"/> 
    </fo:block> 
    <fo:block page-break-inside="auto"> 
     <fo:table> 
      <fo:table-body> 
       <fo:table-row> 
        <fo:table-cell> 
         <fo:block/> 
        </fo:table-cell> 
       </fo:table-row> 
       <xsl:for-each select="reportContent/batch"> 
        <fo:table-row> 
         <fo:table-cell padding="3px"> 
          <fo:block> 
           <xsl:param name="clientId" /> 
          </fo:block> 
         </fo:table-cell> 
        </fo:table-row> 
       </xsl:for-each> 
      </fo:table-body> 
     </fo:table> 
    </fo:block> 
</fo:flow> 

有什麼辦法,我可以用我的xsl:fo標籤內的參數?

回答

1

爲了能夠使用從Java傳遞到<fo:block>標籤內XSLT參數的值,我不得不我的.xsl文件中的<xsl:stylesheet>標籤結束之後初始化參數:

<xsl:param name="clientId" /> 

然後後使用我的內:FO標籤是這樣的:

<fo:block> 
    <xsl:value-of select="$clientId"/> 
</fo:block> 
+0

是的,'的xsl:for傳遞到樣式表的參數param'聲明必須是一個'頂層'元素(https://www.w3.org/TR/xslt#top-level-variables,https://www.w3.org/TR/xslt#dt-top-level),即,是'xsl:stylesheet'元素的子元素。 –

相關問題