Tuesday, June 26, 2012

OSB - Assign and Conditional Branch

The Conditional Branch is not possible directly to handle multiple compares. Using Assign to work around such scenario is doable.

1. Add a pipeline pair before the conditional branch
2. Add a stage in the request pipeline
3. Add an assign action in the stage to create a variable name as x, which will be using in the conditional branch

The XQuery expression in Assign Action:

for $type in $body/request/type
if ((data($type) = 'a') or (data($type) = 'b') or (data($type) = 'c')) then 
    <BranchValue>branch1 < /BranchValue>
else if ((data($type) = 'x') or (data($type) = 'y') or (data($type) = 'z')) then
    <BranchValue>branch2 < /BranchValue>
else ()

Then the conditional branch can work with the variable defined in above step to compare against 'branch1' or 'branch2' as values. The XPath should be $x/BranchValue/text().

1 comment:

ICX Armenia said...

I try to use this, but I'm getting an error, I think is because you only can use the variable inside the stage it was defined