各位会员下午好!我在测试条形码的值时遇到问题。首先,我将向您展示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>条码的值为空。从理论上讲,<xsl:if test="gsmsg/barcode">必须验证是否有值,如果没有,fop就不会读取Barcode4j插件。在我的例子中,消息不起作用,因为如果继续阅读Barcode4j插件,打印就会崩溃,因为条形码的"message“参数不能为空。为什么xsl:if in在我的例子中不起作用?请帮帮我,
致以最好的问候,马可
发布于 2019-01-17 22:31:16
从理论上讲,
<xsl:if test="gsmsg/barcode">测试barcode元素是否存在。
如果要测试文本值是否存在,请执行以下操作:
<xsl:if test="string(gsmsg/barcode)">或者:
<xsl:if test="gsmsg/barcode/text()">https://stackoverflow.com/questions/54237923
复制相似问题