First of all an explanation of Insert And Update Nodes.
This accepts a parent node path, which is the repeating node. So if there is an inquire, the result is the repeating node, so we put WorkData/Inquire/Output/Result as the node path.
It then iterates through all the child nodes and does something (adds some property to the child node or changes something)
So an example of this is a shopping cart with items. If I am iterating through the items in the shopping cart, for each Item I could edit a property of it (like quantity) or add a new property (like a valid flag when performing some check).
Here is a drawing showing how insert and update nodes works for an inquire with 5 results But this is something we are familiar with. This is what a xsl:for-each does.
We know that when we're within one xsl for each, if we have an xsl:value-of within it, it is a continuation of the path. So for example:
Code: Select all
<xsl:for-each select="WorkData/Inquire/Output/Result"/>
<xsl:value-of select="WorkData/Inquire/Output/Result/ItemNumber"/>
</xsl:foreach>
WorkData/Inquire/Output/Result/WorkData/Inquire/Output/Result/ItemNumber
Which we know doesnt exist.
So
Code: Select all
<xsl:for-each select="WorkData/Inquire/Output/Result"/>
<xsl:value-of select="ItemNumber"/>
</xsl:foreach>
To exit the for-each loop, we would need to add a slash in front of the workdata:
Code: Select all
<xsl:for-each select="WorkData/Inquire/Output/Result"/>
<xsl:value-of select="/WorkData/SomeOtherService/Output/Result/VariableToUse"/>
</xsl:foreach>
FEATURE SUGGESTION: when viewing a service, at the service level, it should show in the xml viewer that it actually is placing it in an xsl for each xml
So if we continue and turn on the xsl:for-each for the InsertAndUpdateNodes, we are saying we will do this process multiple times - once for each node in some other parent we are looking. So if we look at the diagram again, it becomes something like this Now, for each Result of AnotherInquire, we are going to run the entire InsertAndUpdateNodes, which itself is running a foreach.
The first difficult is that we might need to put a slash in front of the parent node in the InsertAndUpdateNodes so we can say "I am leaving the loop, I want to start this xpath at workdata again". But this is possible if you wanted to, so its not a big deal, just something extra to think about.
Then you want to think about why you would want to do this. The most common way I have seen this set up is when a developer has two sets of data and wants to give information from one to the other But this is actually the perfect use case for Merge services.
Merge will give all the child nodes from the result on the right side to the left side once they are matched up.
MergeTargetedNodes will ask the developer to specify what child node you want to give from the right to the left once they are matched up
And if you wanted to use the InsertAndUpdateNodes service still, you could use an xsl:variable to help you. See below an example where we used an InsertAndUpdateNodes like a MergeTargetedNodes: