修复xslt验证错误
我需要验证XSLT中Invoice元素的值:缺少元素=默认为1(工作)... blank =默认为1(工作)...但是2或字符串中的任何数字这是不工作,因为它保持返回到1.修复xslt验证错误
<xsl:template match="Transaction" >
<Transaction invoice="{Invoice}">
<xsl:attribute name="invoice">
<xsl:choose>
<xsl:when test="@Invoice and (@Invoice!='') and (@Invoice!='0')">
<xsl:value-of select="@Invoice"/></xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
希望得到你的任何帮助。会很感激。
感谢
在
(好像只有小写是好的)when
病症使用的,而是和
开始从一个简单的条件,并添加一次一个,看看哪一个是坏的:
<xsl:when test="@Invoice">
然后
<xsl:when test="@Invoice and (@Invoice!='')">
然后
<xsl:when test="@Invoice and (@Invoice!='') and (@Invoice!=0)">
althoug我会写
<xsl:when test="@Invoice and (@Invoice > 0)">
这是行不通的,我得到了错误的结果 – user1358072 2013-05-06 14:01:56
最后一行不能大于0,因为它是一个字符串 – user1358072 2013-05-06 14:11:55
对不起,你的问题看起来它们是数字(“.. .. 。但2或任何数字不工作,因为它保持返回1'“) – ilomambo 2013-05-06 14:19:57
是发票的属性或您的输入XML的节点?看起来,你总是在你的默认分支中运行。 'invoice =“{Invoice}'这是使用Invoice作为节点,但'@ Invoice'正在查找Invoice as attribute。 – 2013-05-06 15:05:51
您的问题尚不清楚,但如果您向我们展示了一个例子,我们可能会回答它一个事务元素在你的源文件中 – 2013-05-06 17:26:47