【问题标题】:Why "xsl:if test" don't work on Barcode4j plugin为什么“xsl:if test”在 Barcode4j 插件上不起作用
【发布时间】:2019-01-17 14:19:46
【问题描述】:

各位会员下午好! 我在测试条形码值时遇到问题。 首先,我将向您展示 xsl 和 xml 代码,然后我将解释问题所在。 Xsl代码:

<fo:table-cell  font-size="7" padding="0.5mm" border-width="0.2mm" border-style="transparent">
                                    <fo:block>
                                        <xsl:if test="gsmsg/barcode">
                                            <fo:block>
                                              <fo:instream-foreign-object>
                                              <xsl:variable name="Barcod">
                                              <xsl:value-of select="gsmsg/barcode"/>
                                              </xsl:variable>
                                                        <barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns"
                                                         message="{$Barcod}" orientation="0">
                                                        <barcode:code128>
                                                    <barcode:height>8mm</barcode:height>
                                                </barcode:code128>
                                            </barcode:barcode>
                                              </fo:instream-foreign-object>
                                            </fo:block>
                                        </xsl:if>
                                    </fo:block>
                                </fo:table-cell>

xml源码:

<gsmsg xmlns="">
    <IdentificativoSdI>169077607</IdentificativoSdI>
    <NomeFile>IT01942890995.xml</NomeFile>
    <Formato>FPR12</Formato>
    <MessageId>1185389295</MessageId>
    <TentativiInvio>1</TentativiInvio>
    <Lotto>405</Lotto>
    <attpass>P</attpass>
    <Versione>0.7</Versione>
    <TipoMsg>DO</TipoMsg>
    <barcode/>
    <note/>
</gsmsg>

条形码的值为空。对于 teory &lt;xsl:if test="gsmsg/barcode"&gt; 必须验证是否有值,如果没有,fop 不要读取 Barcode4j 插件。 在我的情况下,&lt;xsl:if test="gsmsg/barcode"&gt; 不起作用,因为继续读取 Barcode4j 插件并且由于条形码的“消息”参数不能为空而导致打印崩溃。 为什么 xsl:if 不能在我的 案子? 请帮帮我,

最好的问候, 马可

【问题讨论】:

    标签: xml xslt barcode4j


    【解决方案1】:

    在理论上,

    <xsl:if test="gsmsg/barcode">
    

    测试barcode 元素是否存在。

    如果要测试文本值是否存在,请执行以下操作:

    <xsl:if test="string(gsmsg/barcode)">
    

    或:

    <xsl:if test="gsmsg/barcode/text()">
    

    【讨论】:

    • 谢谢,非常感谢您的意见。新年好!
    猜你喜欢
    • 2022-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 2017-03-01
    相关资源
    最近更新 更多