Virtual Nodes

Version 22.0.8473


Virtual Nodes


Virtual nodes are special nodes added to the Destination structure that do not directly appear in the output XML. Instead, these virtual nodes provide an opportunity to implement logic that affects the appearance/values of other (non-virtual) nodes in the output.

The XML Map Connector supports three types of virtual nodes:

  • Code Script
  • Condition
  • Loop

Code Script

A code script virtual node provides an opportunity to write custom ArcScript that does not need to return an output value. Often, these nodes will use the special _map item to store values that need to be referenced later in the mapping, but do not need to be output in the current context.

For example, the scenario described in the Map Item section is a good candidate for a virtual code script node. The sum of the line item costs needs to be returned as output outside of the Foreach loop where it is calculated. So, a virtual code script node within the Foreach loop can calculate the value (and not output it), then this value can be referenced (as output) in a non-virtual node outside the loop.

Condition

A condition virtual node groups output elements together based on a shared conditional. All children of the condition node will appear in the output if the condition is true, and not appear if the condition is false.

This is functionally equivalent to adding the same conditional to each of the individual nodes independently. For conditions that affect many different nodes, it is likely more convenient to create a single condition node, and then make all of the relevant output nodes a child of the condition node.

Loop

A loop virtual node functions the same as a Foreach mapping between parent nodes, except that the parent node will not actually appear in the output XML. This allows for ‘flattening’ repeated elements in the Source into a non-hierarchical structure in the Destination. This is easiest to understand via an example.

Take the following input XML:

<!-- example input -->
<Items>
  <DataReading>
    <Temperature>212.5</Temperature>
  </DataReading>
  <DataReading>
    <Temperature>9.2</Temperature>
  </DataReading>
  <DataReading>
    <Temperature>5.1</Temperature>
  </DataReading>
</Items>

This needs to be mapped to a flat structure that includes all of the DataReading data:

<!-- desired output -->
<Items>
  <OutputData>
    <Temperature>212.5</Temperature>
    <Temperature>9.2</Temperature>
    <Temperature>5.1</Temperature>
  </OutputData>
</Items>

This can be accomplished by establishing a Foreach relationship with a Loop node in the Destination corresponding to each DataReading element in the Source:

If the Foreach relationship was established between DataReading and OutputData, then the OutputData element would be repeated in the result. The Loop node avoids this repetition of hierarchy and flattens the value into the single OutputData element.