Reputation: 43
My requirement is to set some dynamic variables in a for loop to the datapower context something like :
<dp:set-variable name="'var://context/txn-info/appErrorInd[$i+1]'"
value="'yes'" />
The variable $i will keep on changing. The above code isn't working. Can somebody give me a solution?
Upvotes: 2
Views: 7093
Reputation: 243479
Use:
<dp:set-variable name="'var:{//context/txn-info/appErrorInd[$i+1]}'"
value="'yes'" />
The above is a mechanical correction of the provided code. Most likely it contains another, more subtle error. To correct this error, too, use:
<dp:set-variable name="'var:{(//context/txn-info/appErrorInd)[$i+1]}'"
value="'yes'" />
Explanation:
Use of AVT.
The []
operator has a higher precedence than the //
pseudo-operator. To override this one needs to use explicitly brackets.
Upvotes: 1