Correct way to declare and use static lists in NxBRE
-
28-05-2021 - |
Question
I am using NxBRE rules engine, and need to be able to check whether some value is in the list. Here is what I try:
Defining the list elements:
<String id="Element1" value="Value1"/>
<String id="Element2" value="Value2"/>
<String id="Element3" value="Value3"/>
<String id="Element4" value="Value4"/>
Checking the condition:
<In valueId="ValueId" idList="Element1, Element2, Element3, Element4">
<ObjectLookup id="ValueId" objectId="MyObject" member="GetValue">
<Argument valueId="MyArgument"/>
</ObjectLookup>
</In>
ObjectLookup
works OK, but the condition never evaluates to true, as I see from the results of the whole set execution.
I.e., if I change In
... valueId
... idList
to mere Equals
... leftId
... rightId
, leave only one id to check against (say, Element4
) and make up a test so that I am sure that my value equals Value4
, I see expected results, which proves that ObjectLookup
works correctly here.
So the questions are:
What I am doing wrong, i.e. why in the same test, where I know that value equals
Value4
,In
does not evaluate into true?Can I do it in a more simple way. I.e., specify a constant list and use it, instead of specifying elements one by one and then constructing list from them?
Is there any good documentation for NxBRE, so I do not have to ask such basic question?
Solution
Looking at the XSL-T that transforms XBRE rules in BRE ones, I think you need to drop the spaces and just use commas to separate the IDs. The example in /Rulefiles/text.xbre works with comma separated IDs.
You could use a regexp, like: (Element1|Element2|Element3|Element4)
There's nothing besides the provided User Guide (PDF) and the online knowledge base. Studying /Rulefiles/text.xbre should also enlighten you somewhat.