简体   繁体   English

在 Datapower 上下文中设置动态变量

[英]Set dynamic variabe in the Datapower context

My requirement is to set some dynamic variables in a for loop to the datapower context something like:我的要求是在 for 循环中为 datapower 上下文设置一些动态变量,例如:

<dp:set-variable name="'var://context/txn-info/appErrorInd[$i+1]'"
                value="'yes'" />

The variable $i will keep on changing.变量 $i 将不断变化。 The above code isn't working.上面的代码不起作用。 Can somebody give me a solution?有人可以给我一个解决方案吗?

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 :说明

  1. Use of AVT .使用AVT

  2. The [] operator has a higher precedence than the // pseudo-operator. []运算符的优先级高于//伪运算符。 To override this one needs to use explicitly brackets.要覆盖这一点,需要明确使用括号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM