简体   繁体   English

Apache FOP XSL文档中使用Barcode4J的动态消息

[英]Dynamic Message using Barcode4J in Apache FOP XSL Document

I'm having trouble generating a dynamic message using Barcode4J ean-13 in an Apache FOP xsl document. 我在使用Apache FOP xsl文档中的Barcode4J ean-13生成动态消息时遇到问题。 I did get the barcode to generate using a hard coded message. 我确实获得了使用硬编码消息生成的条形码。 However, I would like to pass the barcode number to the xsl document as a parameter. 但是,我想将条形码编号作为参数传递给xsl文档。 How do I go about doing that? 我该怎么做?

Also, I have referred to the barcode4J site for help page with no luck. 另外,我也很幸运地访问了条形码4J 网站的帮助页面。 I have tried using the technique described here but had no luck. 我尝试使用这里描述的技术但是没有运气。

This is how my xsl document looks like 这就是我的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>

You don't say which XSLT version you are using. 您没有说您正在使用哪个XSLT版本。

If you want to pass a parameter to your XSLT, you need to declare the parameter as a child element of your xsl:stylesheet , eg: 如果要将参数传递给XSLT,则需要将该参数声明为xsl:stylesheet的子元素,例如:

<xsl:param name="barcode" />

For XSLT 1.0, see http://www.w3.org/TR/xslt#top-level-variables . 对于XSLT 1.0,请参见http://www.w3.org/TR/xslt#top-level-variables You could declare more about it if you are using XSLT 2.0. 如果您使用的是XSLT 2.0,则可以声明更多信息。

How to pass the parameter value will depend on which XSLT processor you are using, but you can expect that to be covered in the XSLT processor's documentation. 如何传递参数值将取决于您所使用的XSLT处理器,但是您可以期望XSLT处理器的文档中介绍该参数。

You can then use the $barcode parameter in an 'attribute value template' in your otherwise-literal markup: 然后,您可以在文字标记的“属性值模板”中使用$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>

For attribute value templates in XSLT 1.0, see http://www.w3.org/TR/xslt#dt-attribute-value-template 有关XSLT 1.0中的属性值模板,请参见http://www.w3.org/TR/xslt#dt-attribute-value-template

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM