Xml 修复用于验证的xslt错误

Xml 修复用于验证的xslt错误,xml,validation,xslt,Xml,Validation,Xslt,我需要验证XSLT中Invoice元素的值:missing element=default为1(工作)…blank=default为1(工作)…但2或字符串中的任何数字不工作,因为它保持返回1 <xsl:template match="Transaction" > <Transaction invoice="{Invoice}"> <xsl:attribute name="invoice"> <xsl:choose>

我需要验证XSLT中Invoice元素的值:missing element=default为1(工作)…blank=default为1(工作)…但2或字符串中的任何数字不工作,因为它保持返回1

<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>

1.
希望得到你的帮助。非常感谢

感谢
中的当
条件使用时,使用AND而不是AND(似乎只有小写字母才好)

从一个简单的条件开始,一次添加一个条件,看看哪一个条件不好:

<xsl:when test="@Invoice">

然后


然后


虽然我会写

<xsl:when test="@Invoice and (@Invoice &gt; 0)">


最后一行它不能大于0,因为它是一个字符串。很抱歉,从您的问题来看,它们似乎是数字(“
…但2或任何因为它一直返回到1而不起作用的数字”)。很抱歉,我应该说字符串中的数字:)我要编辑我的帖子,在输入xml中添加属性或节点吗?看起来,您总是在默认分支中运行
invoice=“{invoice}
这是使用invoice作为节点,但
@invoice
正在查找invoice作为属性。您的问题不清楚,但如果您向我们展示源文档中的事务元素示例,我们可能能够回答。
<xsl:when test="@Invoice and (@Invoice!='') and (@Invoice!=0)">
<xsl:when test="@Invoice and (@Invoice &gt; 0)">