Sirius
Sirius

Reputation: 13

Creating a greater than but less than function in XML

I am trying to write a a code that pulls information from a list in SharePoint that ranges in numbers associated with one term. For instance:

1-3 = Low
4-6 = Moderate
7-9 = High
10 = Critical

I have the following code but I can't seem to get it to work right. What I want to do is it to only pull from these ranges above:

<xsl:variable name="RM1A" select="count($Rows[@Impact $gt;='01' -and- $lt;='03][@Likelihood $gt;='01' -and- $lt;='02'])"/>

The problem is that it works but pulls all numbers that are greater than 01 and doesn't stop at 03. I am completely new at XML coding so be gentle.

I am looking for an easier way maybe or the right syntax for doing this.

Thanks!

Upvotes: 1

Views: 759

Answers (1)

har07
har07

Reputation: 89295

First of all, escaped < and > are, in order, &lt; and &gt;. Then, expression like and &lt;='03' is not valid. It is considered missing left operand of <=. And the last point will be only a suggestion; you might want convert the attributes to number, to safely compare its value as number. So, the following is one possible valid expression (wrapped for readability) :

count(
    $Rows[number(@Impact) &gt;=1 and number(@Impact) &lt;=3]
         [number(@Likelihood) &gt;=1 and number(@Likelihood) &lt;=2]
)

Upvotes: 2

Related Questions