我正在嘗試使用XML和XSLT文件實現FOP來輸出PDF。用FOP修復PDF中一個單詞的位置
我的問題是我需要修復了一行字的位置(而不是通過使用表)以下,例如:
我有以下XML:
<address>
<Line1 length="32" noLine="5" col="60" />
<Line2 length="32" noLine="6" col="60">Mr. John Kane</Line2 >
<Line3 length="32" noLine="7" col="60">15 Street Springfield</Line3 >
<Line4 length="32" noLine="8" col="60" />
<Line5 length="32" noLine="9" col="60" />
<Line6 length="6" noLine="10" col="60">75009</Line6 >
<Line7 length="25" noLine="10" col="67">Freesberg</Line7 >
<Line8 length="25" noLine="11" col="67">Idaho</Line8 >
</address>
- 在哪裏該
length
是單詞/句子長度 noLine
是行號col
在開始口服該行中的單詞/句子的位置
我做了行,但我似乎無法在行中的正確位置(列)插入單詞/句子。
這是我的XSLT部分:
<fo:block font-size="10" font-family="monospace">
<xsl:for-each select="*">
<xsl:variable name="currentNode" select ="name(.)"/>
<xsl:choose>
<xsl:when test="$currentNode = 'address'">
<xsl:for-each select="*">
<xsl:variable name="length" select ="@length"/>
<xsl:variable name="noLine" select ="@noLine"/>
<xsl:variable name="col" select ="@col"/>
<xsl:variable name="precNoLig" select = "preceding-sibling::*[1]/@noLine"/>
<xsl:choose>
<xsl:when test="$precNoLig = $noLine">
<fo:block font-size="10" font-family="monospace" text-indent="60">
 <xsl:value-of select="." />
</fo:block>
</xsl:when>
<xsl:otherwise>
<!--<fo:block font-size="10" font-family="monospace" >-->

<xsl:value-of select="." />
<!--</fo:block>-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</fo:block>
這是預期的輸出爲PDF
:
Mr. John Kane
15 Street Springfield
75009 Freesberg
Idaho
如果它在PDF
(COL)以下職位:
<-----------------60-------------------->
<-----------------60-------------------->Mr. John Kane
<-----------------60-------------------->15 Street Springfield
<-----------------60-------------------->
<-----------------60-------------------->
<-----------------60-------------------->75009 Freesberg
<-----------------67-------------------------->Idaho
任何幫助,將不勝感激。
@DimitreNovatchev這很簡單:我將'xslt'和'xml'文件傳遞給FOP,它爲我生成'PDF' – GingerHead
仍然沒有轉換的預期/希望輸出 - 應該是生成的XSL-FO,然後將其提供給格式化程序。請添加這個缺少的信息。 –
Mike,對不起,但添加的不是來自XSLT轉換的輸出 - 它是來自FOP的輸出。請提供XSLT轉換所需的輸出。 –