[英]Dynamic Message using Barcode4J in Apache FOP XSL Document
我在使用Apache FOP xsl文档中的Barcode4J ean-13生成动态消息时遇到问题。 我确实获得了使用硬编码消息生成的条形码。 但是,我想将条形码编号作为参数传递给xsl文档。 我该怎么做?
另外,我也很幸运地访问了条形码4J 网站的帮助页面。 我尝试使用这里描述的技术,但是没有运气。
这就是我的xsl文档的样子
<fo:block-container left="1000" top="1000"
z-index="1" position="relative">
<fo:block>
<fo:instream-foreign-object>
<bc:barcode xmlns:bc="http://barcode4j.krysalis.org/ns"
message="123456789789">
<bc:ean-13 />
</bc:barcode>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
您没有说您正在使用哪个XSLT版本。
如果要将参数传递给XSLT,则需要将该参数声明为xsl:stylesheet
的子元素,例如:
<xsl:param name="barcode" />
对于XSLT 1.0,请参见http://www.w3.org/TR/xslt#top-level-variables 。 如果您使用的是XSLT 2.0,则可以声明更多信息。
如何传递参数值将取决于您所使用的XSLT处理器,但是您可以期望XSLT处理器的文档中介绍该参数。
然后,您可以在文字标记的“属性值模板”中使用$barcode
参数:
<fo:block-container left="1000" top="1000"
z-index="1" position="relative">
<fo:block>
<fo:instream-foreign-object>
<bc:barcode xmlns:bc="http://barcode4j.krysalis.org/ns"
message="{$barcode}">
<bc:ean-13 />
</bc:barcode>
</fo:instream-foreign-object>
</fo:block>
</fo:block-container>
有关XSLT 1.0中的属性值模板,请参见http://www.w3.org/TR/xslt#dt-attribute-value-template
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.