[英]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.