将XSL-FO url函数转换为模板
我正在使用ApacheFopVersion1.1通过命令行构建pdf 这是我的XSL,运行良好将XSL-FO url函数转换为模板,url,xslt,xsl-fo,param,Url,Xslt,Xsl Fo,Param,我正在使用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" s
<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参数为null
如何传递url并使其工作?如果要引用属性中的变量,需要使用属性值模板 在模板中尝试这一行
<fo:external-graphic content-height="9mm" content-width="9mm" height="10mm" width="10mm"
scaling="non-uniform" src="url({$imgUrl})"/>
大括号表示要求值的表达式,而不是按字面意义上的输出,即当前代码中发生的情况。它实际上是输出文本$imgUrl,而不是变量的值