English 中文(简体)
我在比较XSLT<xsl:if>中的插图时,如何具体说明“不等于”?
原标题:How do I specify "not equals to" when comparing strings in an XSLT <xsl:if>?
  • 时间:2012-05-10 13:19:44
  •  标签:
  • xslt
  • xpath

目前,Im试图打印“面值”的xsl有以下代码,但似乎与<代码>一样。

<xsl:for-each select="Directory/Match">
    <xsl:if test = "Count != N/A">
        <tr>
            <td><xsl:value-of select="@bookName" /></td>
            <td><xsl:value-of select="@AuthorName" /></td>
            <td><xsl:value-of select="Count" /></td>
        </tr>
    </xsl:if>
</xsl:for-each>

然而,如果我试图将其与数字价值进行比较,它就发挥了作用。

例:

<xsl:if test = "Occurrances != 0">

请允许我告诉我:如果我想比较一下我可以使用什么?

最佳回答

正如Freburt所说,但也指出,通常最好写上字。

test="not(Count =  N/A )"

如果只有一个数字要素,它们就意味着同样的东西,但如果没有数字,或者如果有的话,那么意思是不同的。

<>6 YEARS LATER

由于这一答案似乎已广为人知,但对某些读者来说可能没有什么加密,请允许我加以扩大。

XPath的“=”和“!”操作者可以比较两套价值。 总的说来,如果A和B是一套价值观,那么“如果A和B的数值是相等的,那么“=”回报是真实的,而“!” 如果存在任何不公平的公式,回报是真实的。

在普通情况下,如果A选择零或一分点,而B是不变的(即“NA”),这意味着如果A没有,或具有与“NA”不相等的价值,则“A =“NA”/code”即为回报。 相比之下,A !=“NA”,如果A确实存在,但并不等于“NA”。 通常,你想要将“缺席”案件视为“不平等”,这意味着<代码>not(A = “NA”是适当的表述。

问题回答

如果你想比较一下一下,你需要把它放在(引文)中:

<xsl:if test="Count !=  N/A ">




相关问题
When test hanging in an infinite loop

I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

quick xslt for-each question

Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

XSLT Transform XML with Namespaces

I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

XSLT output to HTML

In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

Mangling IDs and References to IDs in XML

I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签