【发布时间】:2013-04-30 06:56:09
【问题描述】:
我需要验证 XSLT 中 Invoice 元素的值:缺少元素 = 默认为 1(工作)...空白 = 默认为 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>
希望能得到你的帮助。将不胜感激。
谢谢
【问题讨论】:
-
Invoice 是输入 xml 中的属性还是节点?似乎,您总是在默认分支中运行。
invoice="{Invoice}this 使用 Invoice 作为节点,但@Invoice正在寻找 Invoice 作为属性。 -
您的问题不清楚,但如果您向我们展示源文档中的 Transaction 元素示例,我们可能能够回答。
标签: xml validation xslt