Topic
  • 27 replies
  • Latest Post - ‏2015-03-10T13:20:19Z by Joseph-Morgan
metroplex
metroplex
26 Posts

Pinned topic How to access current context of for-each from "loop action" Action?

‏2011-06-24T19:06:45Z |
I've looked the forums over in addition to the DP documentation but I haven't been able to find an answer to the following question, hopefully someone can help;

Here's the scenario:

-I define a for-each Action on a processing rule that loops through an XML document based on an XPATH expression.
-I then define an Action to be kicked off for every iteration of that loop.

Here's the question:

How do I access the nodes that were selected by the for-each loop (via the XPATH expression) for each iteration by the Action that's targeted to execute each time? I know how to do it in a stylesheet (via use of the var://service/multistep/loop-iterator variable) but how do I get this info to say, a conditional Action?

Using the output context of the for-each Action as the input context of the targeted Action doesn't seem to work. Nor does specifying AUTO, INPUT or the loop-iterator variable (which would make a lot of sense to be able to do it that way).

I should also add that my for-each is asynch and it creates multiple outputs. Perhaps what I am trying to accomplish cannot be done with merely Actions and will require the use of a stylesheet.

Thanks in advance for any help.
Updated on 2011-07-05T13:37:20Z at 2011-07-05T13:37:20Z by metroplex
  • swlinn
    swlinn
    1348 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-24T20:41:23Z  
    The conditional action requires you to xpath across a document provided in the input context to the conditional action. Unfortunately, having dp:variable('var://service/multistep/loop-iterator') ... or any other DataPower extension function, is not permitted. Thus you need to have a stylesheet that would output the loop-iterator node to an output context that could then be used by your conditional action, if that is what you really wanted to do.

    As far as the output context of the for-each, quite frankly, I've never tried to see the output. I was more interested in the output context of the multiple actions driven through the for-each action, which would be a different context than the input/output of the for-each action anyway. For example, I have used this to run multiple transformations where the stylesheets to be run were in the input context to the for-each, and the transformation action took an initial data context as input as used the same context as its output. It was somewhat like piping the data through multiple transformation actions, but the context had the end result when it was all finished.

    You say the for-each is asynchronous. That would tell me that the for-each iteration doesn't hold up the subsequent actions on your rule. Hopefully you have an event sync in your rule at some point?? As for the actual actions being done in the for-each, you can only specify the input context and output context one time in the configuration, so when you say you are generating multiple outputs, how are you doing that? Are you saving your output of each transformation to a context variable that is uniquely named (var://context/myoutputx where x is the loop iterator count?) It will be helpful if you can give some more detail of what you are trying to do.

    Regards,
    Steve
  • metroplex
    metroplex
    26 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-24T21:17:49Z  
    • swlinn
    • ‏2011-06-24T20:41:23Z
    The conditional action requires you to xpath across a document provided in the input context to the conditional action. Unfortunately, having dp:variable('var://service/multistep/loop-iterator') ... or any other DataPower extension function, is not permitted. Thus you need to have a stylesheet that would output the loop-iterator node to an output context that could then be used by your conditional action, if that is what you really wanted to do.

    As far as the output context of the for-each, quite frankly, I've never tried to see the output. I was more interested in the output context of the multiple actions driven through the for-each action, which would be a different context than the input/output of the for-each action anyway. For example, I have used this to run multiple transformations where the stylesheets to be run were in the input context to the for-each, and the transformation action took an initial data context as input as used the same context as its output. It was somewhat like piping the data through multiple transformation actions, but the context had the end result when it was all finished.

    You say the for-each is asynchronous. That would tell me that the for-each iteration doesn't hold up the subsequent actions on your rule. Hopefully you have an event sync in your rule at some point?? As for the actual actions being done in the for-each, you can only specify the input context and output context one time in the configuration, so when you say you are generating multiple outputs, how are you doing that? Are you saving your output of each transformation to a context variable that is uniquely named (var://context/myoutputx where x is the loop iterator count?) It will be helpful if you can give some more detail of what you are trying to do.

    Regards,
    Steve
    Hey Steve, thanks for the reply, sincerely. I'll answer your questions/clarify below (your comments are underlined);

    The conditional action requires you to xpath across a document provided in the input context to the conditional action. Unfortunately, having dp:variable('var://service/multistep/loop-iterator') ... or any other DataPower extension function, is not permitted.

    Yes, I understand this, that the for-each operates on an incoming XML document specified by the input context. As such, I have the document that I want to "loop" over going into the for-each; no worries here. What I want to do to the document is to loop through all of the FOO nodes and then have an Action operate on each one of those nodes. Therefore I have specified an Action to be triggered per each iteration, it just so happens that the Action I want triggered is a conditional.

    In order to execute the conditional, I need to have access to the FOO node that was "torn" out of the original document by the XPATH expression of the for-each Action. I'm asking how I get access to the specific FOO node for each iteration so that I can evaluate my conditional against it. If I were to use a stylesheet (because I selected a TRANSFORM Action in my for-each Action as opposed to a CONDITIONAL action) then I could simply use the 'var://service/multistep/loop-iterator' variable. However, I'd rather just pump each FOO node right into the conditional Action.

    As I mentioned before, I tried setting the input context of the conditional to the 'var://service/multistep/loop-iterator' variable as it would make sense that since the XPATH used by the for-loop would tear off the FOO node that I could just route that nodeset into the input of the conditional. However, no luck here.

    You say the for-each is asynchronous. That would tell me that the for-each iteration doesn't hold up the subsequent actions on your rule. Hopefully you have an event sync in your rule at some point??

    Yep, no doubt, I sync a number of asynch Actions before I combine everything together at the end. I indicated that it was asynch because sometimes that has bearing on what output contexts things have to be stored to; didn't know if it made any difference here.

    ... you can only specify the input context and output context one time in the configuration, so when you say you are generating multiple outputs, how are you doing that?

    While it's true that you can only set a single output context for a for-each Action you can also indicate that you want to use multiple outputs. When you do this then every iteration of the for-each Action creates a new output context named by using the value you supplied as the output context as a template. So, for example, if I set the output context to "LOOP_OUT_ITERATION" then for each iteration of my for-each an output context will be created called "LOOP_OUT_ITERATION_X" where X is the iteration number of the current loop.

    Hope this helps clarify things.

    thanks again.
  • Liv2luv
    Liv2luv
    573 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-25T13:12:48Z  
    • metroplex
    • ‏2011-06-24T21:17:49Z
    Hey Steve, thanks for the reply, sincerely. I'll answer your questions/clarify below (your comments are underlined);

    The conditional action requires you to xpath across a document provided in the input context to the conditional action. Unfortunately, having dp:variable('var://service/multistep/loop-iterator') ... or any other DataPower extension function, is not permitted.

    Yes, I understand this, that the for-each operates on an incoming XML document specified by the input context. As such, I have the document that I want to "loop" over going into the for-each; no worries here. What I want to do to the document is to loop through all of the FOO nodes and then have an Action operate on each one of those nodes. Therefore I have specified an Action to be triggered per each iteration, it just so happens that the Action I want triggered is a conditional.

    In order to execute the conditional, I need to have access to the FOO node that was "torn" out of the original document by the XPATH expression of the for-each Action. I'm asking how I get access to the specific FOO node for each iteration so that I can evaluate my conditional against it. If I were to use a stylesheet (because I selected a TRANSFORM Action in my for-each Action as opposed to a CONDITIONAL action) then I could simply use the 'var://service/multistep/loop-iterator' variable. However, I'd rather just pump each FOO node right into the conditional Action.

    As I mentioned before, I tried setting the input context of the conditional to the 'var://service/multistep/loop-iterator' variable as it would make sense that since the XPATH used by the for-loop would tear off the FOO node that I could just route that nodeset into the input of the conditional. However, no luck here.

    You say the for-each is asynchronous. That would tell me that the for-each iteration doesn't hold up the subsequent actions on your rule. Hopefully you have an event sync in your rule at some point??

    Yep, no doubt, I sync a number of asynch Actions before I combine everything together at the end. I indicated that it was asynch because sometimes that has bearing on what output contexts things have to be stored to; didn't know if it made any difference here.

    ... you can only specify the input context and output context one time in the configuration, so when you say you are generating multiple outputs, how are you doing that?

    While it's true that you can only set a single output context for a for-each Action you can also indicate that you want to use multiple outputs. When you do this then every iteration of the for-each Action creates a new output context named by using the value you supplied as the output context as a template. So, for example, if I set the output context to "LOOP_OUT_ITERATION" then for each iteration of my for-each an output context will be created called "LOOP_OUT_ITERATION_X" where X is the iteration number of the current loop.

    Hope this helps clarify things.

    thanks again.
    Not sure if I've followed the discussion in its true sense...

    >In order to execute the conditional, I need to have access to the FOO node that was "torn" out of the original document by the XPATH expression of the for-each Action. I'm asking how I get access to the specific FOO node for each iteration so that I can evaluate my conditional against it.

    In the preceding xform action, I would try to take the FOO node into a context variable and access the same in the loop Action stylesheet for conditional processing.

    Thanks.
  • metroplex
    metroplex
    26 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-27T13:04:07Z  
    • Liv2luv
    • ‏2011-06-25T13:12:48Z
    Not sure if I've followed the discussion in its true sense...

    >In order to execute the conditional, I need to have access to the FOO node that was "torn" out of the original document by the XPATH expression of the for-each Action. I'm asking how I get access to the specific FOO node for each iteration so that I can evaluate my conditional against it.

    In the preceding xform action, I would try to take the FOO node into a context variable and access the same in the loop Action stylesheet for conditional processing.

    Thanks.
    Liv2Luv, thanks for your reply, you stated;

    >In the preceding xform action, I would try to take the FOO node into a context variable and access the same in the loop Action stylesheet for conditional processing.

    Unfortunately the XFORM that is doing this work IS the for-each. That's my question, by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

    I've been disappointed (with the device) at this point that I can't seem to use it without dropping to a stylesheet. Again, maybe I'm just missing the proper way to configure it?

    thanks.
  • Liv2luv
    Liv2luv
    573 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-27T16:11:22Z  
    • metroplex
    • ‏2011-06-27T13:04:07Z
    Liv2Luv, thanks for your reply, you stated;

    >In the preceding xform action, I would try to take the FOO node into a context variable and access the same in the loop Action stylesheet for conditional processing.

    Unfortunately the XFORM that is doing this work IS the for-each. That's my question, by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

    I've been disappointed (with the device) at this point that I can't seem to use it without dropping to a stylesheet. Again, maybe I'm just missing the proper way to configure it?

    thanks.
    Hi,

    >...by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

    How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Further, see the attached sample loopback XML firewall to understand if there is any gap between our understanding. Input for the object is:

    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <joe:Order xmlns:joe=
    "http://joe.com"> <joe:metaInfo> <joe:itemCount>4</joe:itemCount> <joe:minquantity>10</joe:minquantity> </joe:metaInfo> <joe:Item> <joe:Qty>5</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>7</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>9</joe:Qty> <joe:ProdID>78-697-24</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>12</joe:Qty> <joe:ProdID>091356-3</joe:ProdID> </joe:Item> </joe:Order>
    


    processing flow:

    INPUT xform1 PIPE -> PIPE For-each(contains LoopAction xform2) dpvar -> NULL xform3 PIPE -> PIPE Results

    Multiple-outputs for For-each action is ON

    xform1 = joe-meta-info-node.xsl
    xform2 = pseudo-for-each-logic.xsl
    xform3 = joe-final-order-combiner.xsl

    joe-meta-info-node.xsl
    This stylesheet takes the <joe:metaInfo> nodeset into a context variable

    pseudo-for-each-logic.xsl
    1. If condition verifies the loop happens upto the # of times of the <joe:itemCount> element's value
    2. If <joe:minquantity> element's value is less than the <joe:Qty> element's value; do-something...
    3. Otherwise consider as a valid order quantity and copy it further

    joe-final-order-combiner.xsl
    copies metaInfo and valid orders as an output.

    Thanks.
  • Liv2luv
    Liv2luv
    573 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-27T16:12:22Z  
    • Liv2luv
    • ‏2011-06-27T16:11:22Z
    Hi,

    >...by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

    How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Further, see the attached sample loopback XML firewall to understand if there is any gap between our understanding. Input for the object is:

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <joe:Order xmlns:joe= "http://joe.com"> <joe:metaInfo> <joe:itemCount>4</joe:itemCount> <joe:minquantity>10</joe:minquantity> </joe:metaInfo> <joe:Item> <joe:Qty>5</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>7</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>9</joe:Qty> <joe:ProdID>78-697-24</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>12</joe:Qty> <joe:ProdID>091356-3</joe:ProdID> </joe:Item> </joe:Order> </pre>

    processing flow:

    INPUT xform1 PIPE -> PIPE For-each(contains LoopAction xform2) dpvar -> NULL xform3 PIPE -> PIPE Results

    Multiple-outputs for For-each action is ON

    xform1 = joe-meta-info-node.xsl
    xform2 = pseudo-for-each-logic.xsl
    xform3 = joe-final-order-combiner.xsl

    joe-meta-info-node.xsl
    This stylesheet takes the <joe:metaInfo> nodeset into a context variable

    pseudo-for-each-logic.xsl
    1. If condition verifies the loop happens upto the # of times of the <joe:itemCount> element's value
    2. If <joe:minquantity> element's value is less than the <joe:Qty> element's value; do-something...
    3. Otherwise consider as a valid order quantity and copy it further

    joe-final-order-combiner.xsl
    copies metaInfo and valid orders as an output.

    Thanks.
    here is the attachment.
  • metroplex
    metroplex
    26 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-27T16:50:04Z  
    • Liv2luv
    • ‏2011-06-27T16:11:22Z
    Hi,

    >...by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

    How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Further, see the attached sample loopback XML firewall to understand if there is any gap between our understanding. Input for the object is:

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <joe:Order xmlns:joe= "http://joe.com"> <joe:metaInfo> <joe:itemCount>4</joe:itemCount> <joe:minquantity>10</joe:minquantity> </joe:metaInfo> <joe:Item> <joe:Qty>5</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>7</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>9</joe:Qty> <joe:ProdID>78-697-24</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>12</joe:Qty> <joe:ProdID>091356-3</joe:ProdID> </joe:Item> </joe:Order> </pre>

    processing flow:

    INPUT xform1 PIPE -> PIPE For-each(contains LoopAction xform2) dpvar -> NULL xform3 PIPE -> PIPE Results

    Multiple-outputs for For-each action is ON

    xform1 = joe-meta-info-node.xsl
    xform2 = pseudo-for-each-logic.xsl
    xform3 = joe-final-order-combiner.xsl

    joe-meta-info-node.xsl
    This stylesheet takes the <joe:metaInfo> nodeset into a context variable

    pseudo-for-each-logic.xsl
    1. If condition verifies the loop happens upto the # of times of the <joe:itemCount> element's value
    2. If <joe:minquantity> element's value is less than the <joe:Qty> element's value; do-something...
    3. Otherwise consider as a valid order quantity and copy it further

    joe-final-order-combiner.xsl
    copies metaInfo and valid orders as an output.

    Thanks.
    Liv2luv, again, thanks for your reply. From your response;

    > How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Yes, I can get it to work like this. When I involve a stylesheet then I can directly access the loop-iterator variable. What I was hoping for was to be able to do it via just the built in Actions so that the flow represents visually via the GUI what's going on.

    Here's a detailed example to help me explain further. Again, in my opinion the devices should be able to handle something like this without having to use a XFORM.

    Here's the XML that comes into the for-each loop:

    <COMPANY>
    <PRODUCT>
    <FOO>
    </FOO>
    </PRODUCT>
    </COMPANY>
  • metroplex
    metroplex
    26 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-27T17:14:22Z  
    • Liv2luv
    • ‏2011-06-27T16:11:22Z
    Hi,

    >...by default, the for-each applies the XPATH expression to the incoming XML and then places the result (for each iteration) into the var://service/multistep/loop-iterator context variable. I'm trying to use the value of this variable via the Action that's registered in the for-each to execute on every iteration of the loop.

    How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Further, see the attached sample loopback XML firewall to understand if there is any gap between our understanding. Input for the object is:

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <joe:Order xmlns:joe= "http://joe.com"> <joe:metaInfo> <joe:itemCount>4</joe:itemCount> <joe:minquantity>10</joe:minquantity> </joe:metaInfo> <joe:Item> <joe:Qty>5</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>7</joe:Qty> <joe:ProdID>32145-12</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>9</joe:Qty> <joe:ProdID>78-697-24</joe:ProdID> </joe:Item> <joe:Item> <joe:Qty>12</joe:Qty> <joe:ProdID>091356-3</joe:ProdID> </joe:Item> </joe:Order> </pre>

    processing flow:

    INPUT xform1 PIPE -> PIPE For-each(contains LoopAction xform2) dpvar -> NULL xform3 PIPE -> PIPE Results

    Multiple-outputs for For-each action is ON

    xform1 = joe-meta-info-node.xsl
    xform2 = pseudo-for-each-logic.xsl
    xform3 = joe-final-order-combiner.xsl

    joe-meta-info-node.xsl
    This stylesheet takes the <joe:metaInfo> nodeset into a context variable

    pseudo-for-each-logic.xsl
    1. If condition verifies the loop happens upto the # of times of the <joe:itemCount> element's value
    2. If <joe:minquantity> element's value is less than the <joe:Qty> element's value; do-something...
    3. Otherwise consider as a valid order quantity and copy it further

    joe-final-order-combiner.xsl
    copies metaInfo and valid orders as an output.

    Thanks.
    (PLEASE DISREGARD MY RESPONSE DIRECTLY ABOVE THIS ONE - IT WAS UNFINISHED WHEN THE BROWSER SUBMITTED IT, SORRY)

    Liv2luv, again, thanks for your reply. From your response;

    > How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Yes, I can get it to work like this. When I involve a stylesheet then I can directly access the loop-iterator variable. What I was hoping for was to be able to do it via just the built in Actions so that the flow represents visually via the GUI what's going on.

    Here's a detailed example to help me explain further. Again, in my opinion the devices should be able to handle something like this without having to use a XFORM.

    Here's an example XML that comes into the for-each loop:

    <COMPANY>
    <PRODUCT>
    <FOO>
    <ID>1</ID>
    <FEATURE>HOT</FEATURE>
    </FOO>
    <FOO>
    <ID>2</ID>
    <FEATURE>WARM</FEATURE>
    </FOO>
    <FOO>
    <ID>3</ID>
    <FEATURE>COLD</FEATURE>
    </FOO>
    </PRODUCT>
    </COMPANY>

    I can have many <FOO> items so I use the XPATH expression //FOO to force the for-each to iterate through each one. As the for-each iterates through each one it places each <FOO> node set into the var://service/multistep/loop-iterator variable. So, the variable will hold the following values (once per each iteration);

    ITERATION 1:
    <FOO>
    <ID>1</ID>
    <FEATURE>HOT</FEATURE>
    </FOO>

    ITERATION 2:
    <FOO>
    <ID>2</ID>
    <FEATURE>WARM</FEATURE>
    </FOO>

    ITERATION 3:
    <FOO>
    <ID>3</ID>
    <FEATURE>COLD</FEATURE>
    </FOO>

    I realize that I can grab these through a stylesheet, however, the for-each allows me to specify an Action to kick off for each iteration (other than a XFORM). What I'd like to do is to specify a conditional Action that looks at the <FEATURE> node of each independent <FOO> node as it's iterated on. I want to do something different based on whether it's HOT, WARM or COLD.

    My question is, can I get the currently iterated node into a conditional (or other) Action without having to "shell" out to a stylesheet? I would think that access to the currently iterated node would seem to be the entire point of a for-each Action. The fact that the for-each allows you to specify essentially any other Action as one that gets "executed" for each iteration leads me to believe that we should be able to just "pipe" the input info from the current for-each iteration into the per iteration Action.

    I realize that there are other work arounds and I truly appreciate the samples that have been posted in this thread. I guess I'm just expecting that devices of this caliber should be able to do this sort of thing trivially. By moving the logic into a stylesheet and away from the GUI the flow for the rule is getting buried (in my opinion).

    thanks.
  • Liv2luv
    Liv2luv
    573 Posts

    Re: How to access current context of for-each from "loop action" Action?

    ‏2011-06-27T18:35:26Z  
    • metroplex
    • ‏2011-06-27T17:14:22Z
    (PLEASE DISREGARD MY RESPONSE DIRECTLY ABOVE THIS ONE - IT WAS UNFINISHED WHEN THE BROWSER SUBMITTED IT, SORRY)

    Liv2luv, again, thanks for your reply. From your response;

    > How about using an extension function dp:transform(stylesheet, nodeset) for each nodeset contained in var://service/multistep/loop-iterator context variable.

    Yes, I can get it to work like this. When I involve a stylesheet then I can directly access the loop-iterator variable. What I was hoping for was to be able to do it via just the built in Actions so that the flow represents visually via the GUI what's going on.

    Here's a detailed example to help me explain further. Again, in my opinion the devices should be able to handle something like this without having to use a XFORM.

    Here's an example XML that comes into the for-each loop:

    <COMPANY>
    <PRODUCT>
    <FOO>
    <ID>1</ID>
    <FEATURE>HOT</FEATURE>
    </FOO>
    <FOO>
    <ID>2</ID>
    <FEATURE>WARM</FEATURE>
    </FOO>
    <FOO>
    <ID>3</ID>
    <FEATURE>COLD</FEATURE>
    </FOO>
    </PRODUCT>
    </COMPANY>

    I can have many <FOO> items so I use the XPATH expression //FOO to force the for-each to iterate through each one. As the for-each iterates through each one it places each <FOO> node set into the var://service/multistep/loop-iterator variable. So, the variable will hold the following values (once per each iteration);

    ITERATION 1:
    <FOO>
    <ID>1</ID>
    <FEATURE>HOT</FEATURE>
    </FOO>

    ITERATION 2:
    <FOO>
    <ID>2</ID>
    <FEATURE>WARM</FEATURE>
    </FOO>

    ITERATION 3:
    <FOO>
    <ID>3</ID>
    <FEATURE>COLD</FEATURE>
    </FOO>

    I realize that I can grab these through a stylesheet, however, the for-each allows me to specify an Action to kick off for each iteration (other than a XFORM). What I'd like to do is to specify a conditional Action that looks at the <FEATURE> node of each independent <FOO> node as it's iterated on. I want to do something different based on whether it's HOT, WARM or COLD.

    My question is, can I get the currently iterated node into a conditional (or other) Action without having to "shell" out to a stylesheet? I would think that access to the currently iterated node would seem to be the entire point of a for-each Action. The fact that the for-each allows you to specify essentially any other Action as one that gets "executed" for each iteration leads me to believe that we should be able to just "pipe" the input info from the current for-each iteration into the per iteration Action.

    I realize that there are other work arounds and I truly appreciate the samples that have been posted in this thread. I guess I'm just expecting that devices of this caliber should be able to do this sort of thing trivially. By moving the logic into a stylesheet and away from the GUI the flow for the rule is getting buried (in my opinion).

    thanks.
    Hi,

    >My question is, can I get the currently iterated node into a conditional (or other) Action without having to "shell" out to a stylesheet?

    Yes. I've done it this way...If you're modifying the existing For-each action:

    1. double click on For-each action
    2. Click on Loop action hyperlink
    3. Click on advanced tab of configure transform action
    4. select the dropdown as conditional for action type
    5. Apply the relative Xpath (/FOO/FEATURE​&​#8203;text()=HOT​&​#8203;)for var://service/multistep/loop-iterator nodeset
    6. Apply a stylesheet for each different feature :)

    If you are routing various Feature nodesets... then route action (based on xpath) would be most appropriate and there will be no stylesheets to write.

    Thanks.