2012-02-29 11 views
1

Windows XPでApache FOP v.1.0(最新)を使用しています。パラメータを使用したいと思います。私はさまざまなパラメータ構文を使用しましたが、 "fop"はそれを使用しません。ドキュメントには、 "-param name value"と書かれています。私のXMLファイルの"-param"のApache FOPの使用

パーツ:

<letter position="1"> 

私は私のXSLTファイルを持っている:

<xsl:param name="position"/> 
<xsl:for-each select="letter[@position=$position]"> 

次作品:

<xsl:for-each select="letter[@position=1]"> 

そして、これも動作します:

<xsl:param name="position" select="1"/> 
<xsl:for-each select="letter[@position=$position]"> 

したがってFOPは入力を取得しません。

コマンド私は動作しませんでした、試してみました:

fop -param position 1 -xml data.xml -xsl stylesheet.xsl -pdf output.pdf 
fop -xml data.xml -param position 1 -xsl stylesheet.xsl -pdf output.pdf 
fop -xml data.xml -xsl stylesheet.xsl -param position 1 -pdf output.pdf 
fop -xml data.xml -xsl stylesheet.xsl -pdf output.pdf -param position 1 

fop -xml data.xml -xsl stylesheet.xsl -pdf output.pdf -param "position" 1 
fop -xml data.xml -xsl stylesheet.xsl -pdf output.pdf -param position "1" 
fop -xml data.xml -xsl stylesheet.xsl -pdf output.pdf -param "position" "1" 

fop -xml data.xml -xsl stylesheet.xsl -param "position" 1 -pdf output.pdf 
fop -xml data.xml -xsl stylesheet.xsl -param position "1" -pdf output.pdf 
fop -xml data.xml -xsl stylesheet.xsl -param "position" "1" -pdf output.pdf 

fop -xml data.xml -param "position" 1 -xsl stylesheet.xsl -pdf output.pdf 
fop -xml data.xml -param position "1" -xsl stylesheet.xsl -pdf output.pdf 
fop -xml data.xml -param "position" "1" -xsl stylesheet.xsl -pdf output.pdf 

fop -param "position" 1 -xml data.xml -xsl stylesheet.xsl -pdf output.pdf 
fop -param position "1" -xml data.xml -xsl stylesheet.xsl -pdf output.pdf 
fop -param "position" "1" -xml data.xml -xsl stylesheet.xsl -pdf output.pdf 

私はProcessing FOP with parametersに見えたが、彼らは作業の例を与えることはありません。

多くのおかげで、

答えて

0

xsl:stylesheetのあなたのxsl:param子であるか、xsl:templateでそれを持っているのですか? xsl:stylesheetの直接の子である必要があります。ここで

は実施例である...

XML入力(param_test.xml)

<doc> 
    <letter position="1">position 1</letter> 
    <letter position="2">position 2</letter> 
    <letter position="3">position 3</letter> 
    <letter position="4">position 4</letter> 
</doc> 

XSLT 1.0(param_test.xsl)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output indent="yes"/> 
    <xsl:strip-space elements="*"/> 

    <xsl:param name="position"/> 

    <xsl:template match="/doc"> 
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
     <fo:layout-master-set> 
     <fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in"> 
      <fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/> 
     </fo:simple-page-master> 
     </fo:layout-master-set> 
     <fo:page-sequence master-reference="my-page"> 
     <fo:flow flow-name="xsl-region-body"> 
      <xsl:for-each select="letter[@position=$position]"> 
      <fo:block> 
       <xsl:value-of select="."/> 
      </fo:block> 
      </xsl:for-each> 
     </fo:flow> 
     </fo:page-sequence> 
    </fo:root> 
    </xsl:template> 
</xsl:stylesheet> 

FOPコマンドライン(Windows XPではバージョン1.0)

fop -xml param_test.xml -xsl param_test.xsl -pdf param_test.pdf -param position 1 

PDF出力(param_test.pdf)

enter image description here

+0

私は(<のxsl:テンプレート...)テンプレートにパラメータを置きます。できます!どうもありがとう。 – user74952

+0

それでは、私は '<?xml version =" 1.0 "encoding =" utf-8 "?> ' ' 「 」「 」 ' – user74952

+0

@ user74952 - あなたは大歓迎です! –

関連する問題