我正在使用ApacheFOPVersion1.1构建一个pdf (通过命令行)--这里是我的XSL,运行良好
<fo:table-row >
<fo:table-cell >
<fo:block >
<fo:external-graphic content-height="9mm" content-width="9mm" height="10mm" width="10mm" scaling="non-uniform" src="url(./images/pict2.jpg)" />
</fo:block>
</fo:table-cell>
</fo:table-row >如果我试图使用这样声明的模板
<xsl:template name="myRow" >
<xsl:param name="imgUrl"/>
<fo:table-row >
<fo:table-cell >
<fo:block >
<fo:external-graphic content-height="9mm" content-width="9mm" height="10mm" width="10mm" scaling="non-uniform" src="url($imgUrl)"/>
</fo:block>
</fo:table-cell>
</fo:table-row >
</xsl:template>我称之为
<xsl:call-template name="myRow">
<xsl:with-param name="imgUrl" select="'./images/pict2.jpg'" />
</xsl:call-template>没有显示图像。如果我编写了select="./images/pict2.jpg“(没有单引号),那么imgUrl参数是空的,我如何传递url并使它工作呢?
发布于 2014-05-12 17:10:03
如果要引用属性中的变量,则需要使用属性值模板。
在模板中尝试这一行
<fo:external-graphic content-height="9mm" content-width="9mm" height="10mm" width="10mm"
scaling="non-uniform" src="url({$imgUrl})"/>花括号表示要计算的表达式,而不是字面上的输出(这就是当前发生在代码中的情况)。它实际上是输出文本$imgUrl,而不是变量的值)。
https://stackoverflow.com/questions/23612484
复制相似问题