XSLT确定参数是null还是空,然后执行某些操作
我正在尝试确定.././优惠券代码是空的还是空的。我在这个线程中尝试了这些方法,但没有效果。也许我做错了什么XSLT确定参数是null还是空,然后执行某些操作,xslt,Xslt,我正在尝试确定.././优惠券代码是空的还是空的。我在这个线程中尝试了这些方法,但没有效果。也许我做错了什么 <!--Coupon Code Name and Code--> <xsl:choose> <xsl:when test="not(../../coupon_code)"> <xsl:if test="../../coupon_code != ''">
<!--Coupon Code Name and Code-->
<xsl:choose>
<xsl:when test="not(../../coupon_code)">
<xsl:if test="../../coupon_code != ''">
<xsl:value-of select="../../coupon_rule_name" /> <xsl:value-of select="../../coupon_code" /><xsl:value-of select="$sepend" />D.PROMOTION<xsl:value-of select="$sepend" />
</xsl:if>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<!--End Coupon Code Name and Code-->
D.晋升
我在做什么
<xsl:when test="not(../../coupon_code)">
<xsl:if test="../../coupon_code != ''">
来确定它是否为空。那么,我在做什么
<xsl:if test="../../coupon_code != ''">
来确定它是否为空
但是,我查看的数据中有明确的填充,并且根本没有输入when/if
来显示数据。所以它在某个地方失败了,我不知道在哪里
有时,。/../优惠券\优惠券代码
中会包含优惠券代码,如COUPON122。有时候里面什么都没有。你可以检查一下
<xsl:if test="normalize-space(../../coupon_code)">
<xsl:value-of select="../../coupon_rule_name" /> <xsl:value-of select="../../coupon_code" /><xsl:value-of select="$sepend" />D.PROMOTION<xsl:value-of select="$sepend" />
</xsl:if>
D.晋升
仅当
。/../tup\u code
元素包含一些非空白内容时,才处理xsl:value的s。请显示一个最小但完整且具有代表性的输入示例,以及您想要的结果和您得到的结果。如果没有任何XML输入示例和XSLT片段的上下文,我们无法判断代码是否有意义。在任何情况下,如果您选中not(../../../touch\u code)
,您将检查touch\u code
元素是否不存在,因此我不明白您希望如何输入xsl:if
来将不存在的元素与某物进行比较。@MartinHonnen有时,。/../touch\u code
将包含一个优惠券代码,比如COUPON122。有时它里面什么都没有。正如我所说的,没有上下文,我们无法判断这个片段,除了指出test=“not(../../../优惠券代码)”
检查优惠券代码是否根本不存在。如果输入总是包含该元素,那么您的检查意味着您得到执行为空的xsl:others
。