|
Below
is an example of how to combine two different simple DOMs with 1 Repeat Action
and 1 Map action.
Explanation:
The key to the simplicity of this solution is the use of the XPath union (
vertical bar | ) operator. The
union operator creates a single node list for the Repeat Loop to process from
two or more XPath location specifications.
The
unioned XPath specifications for the Source of the Repeat for Element action in
this case are shown below. The not
so obvious part of the solution is the use of the createXPath() method.
This ECMAScript extension method is how xCommerce creates DOM nodes using
the XPath syntax (Note: XPath was created to be an XML document hierarchy search
language making it well suited to the Source side of an xCommerce Map action.
xCommerce's architects decided to also use XPath for writing XML
document's on the Target side of a Map action - hence the need to create the
createXPath() method.) createXPath() takes a string (representing a valid XPath
expression) as its argument. In
this case, we generate the string by simply returning the name of the node being
processed (notice the use of the alias TWODOMs) by the Repeat Loop using the DOM
Node property called nodeName. createXPath()
however, is limited in its XPath support. It
only allows the abbreviated ( slash separated strings ) XPath syntax and only
accepts ordinal selection criteria.
Below
is an example of how to combine two DOMs of the same
hierarchy with 1 Repeat Action and 1 Map action.
Note:
In the sample applications that install with xCommerce there is a combine
documents example. The syntax in this example is incorrect. The appropriate
way to combine documents is shown in this article.
|