The XML mapping editor is a visual data mapping tool that
is designed to transform any combination of XML schema, DTD, or XML
documents and produce a deployable transformation document. You can
map XML-based documents graphically by connecting elements from a
source document to elements of a target document. You can extend built-in
transformation functions using custom XPath expressions and XSLT templates.
The mapping tool automates XSL code generation and produces a transformation
document based on the mapping information you provide.
| Mapping transformation examples |
Description |
| Purchase order to shipping order map |
This example illustrates a business scenario
in which two business units need to seamlessly exchange information.
In this scenario, a purchase order document from the sales department
is mapped to a shipping order document in the logistics department.
The mapping consists of the following key transformations:- Move
- Concatenation
- Inline map
- Substring
- Group
- Custom
|
| Move |
This example demonstrates how the value of an
element in the source document is moved to an element in the target
document. |
| Concatenation |
This example demonstrates how the values from
a set of items in the source document are concatenated into a single
value of an item in the target document. |
| Local map |
This example demonstrates how to create a map
within a map to enable transformation of complex elements within their
own context. |
| Substring |
This example demonstrates how to split the value
of an element in the source document and copy the result to an element
in the target document. |
| Group |
This example demonstrates how to group elements
in the source document and store the result in the target document. |
| Custom |
This examples demonstrates how you can extend
the built-in transform functions of the mapping tool using XPath expressions. |
Purchase order to shipping order
map
In this example, a purchase order document from the
sales department must be processed by the logistics department to
generate a shipping order document.
- To launch the XML Mapping wizard, select: . Click Next.
- In the New Data Mapping File Window, click the folder XMLMappingExamples.
In the File name field, type MyOrderMapping.map,
and then click Next.
- Beside the Root inputs pane, click Add.
- In the Files of type list, select XML Schema and
then click Browse. Expand , select PurchaseOrder.xsd,
and click OK.
- In the Global Elements and Types pane, click PurchaseOrder as
the source root element, and click OK.
- Beside the Root outputs pane, click Add.
- In the Files of type list, select XML Schema,
and click Browse. Expand , select ShippingOrder.xsd, and
click OK.
- In the Global Elements and Types pane, click ShippingOrder as
the target root element and click OK.
- Click Next.
- Beside the Data sample inputs for testing pane, click Add.
Click PurchaseOrder.xml and click OK.
Note: Use
a sample XML input file to test your mapping transformations.
- Click Finish.
Move
In this example, the
value of the OrderID element in the PurchaseOrder document is moved
to the value of the PurchaseOrderReference attribute in the ShippingOrder
document.
- If not already open, right-click MyOrderMapping.map and click Open.
The mapping editor opens.
- In the mapping editor, click the element OrderID from
PurchaseOrder and drag it to the PurchaseOrderReference attribute
in ShippingOrder.

Concatenation
In this example,
the first, middle, and last name elements of the PurchaseOrder document
are concatenated into a single value for the CustomerName element
in the ShippingOrder document.
- In PurchaseOrder, expand the Customer element.
- In PurchaseOrder, click the FirstName element
and drag it to the CustomerName element in
ShippingOrder.
- Add the LastName element:
- In PurchaseOrder, click the LastName element
and drag it to the Move transform type box
between PurchaseOrder and ShippingOrder. The Connection Selection
Helper window opens.
- In the Connection Selection Helper window, click Primary
Connection.
- Add the MiddleInitial element:
- In PurchaseOrder, click the MiddleInitial element
and drag it to the Concat transform type box
between PurchaseOrder and ShippingOrder. The Connection Selection
Helper window opens.
- In the Connection Selection Helper window, click Primary
Connection. The window closes and the transform type changes
to Concat.

- Right-click the Concat box, and click .
- In the Properties view, click the Order tab.
In the Inputs pane, click in the Properties view. Click MiddleInitial:
string and then click the up arrow Reorder icon
to change the order of the concatenated strings.
Tip: You
can customize concatenation options for ordering, delimiters, prefix,
and postfix.

Local map
In this example,
both the source and target documents contain the complex element ShippingAddress.
- In PurchaseOrder, expand the ShippingInfo element.
- In PurchaseOrder, click the ShippingAddress element
and drag it to the ShippingAddress element
in ShippingOrder.

- Edit the Local map by clicking the link in the information window
that opens, or by clicking the edit icon which is in the upper-right
corner of the Local Map transform type box.
The editor opens for the local map.
- You must map transforms for each ShippingAddress sub-element:
- Map the StreetNumber, StreetAddress and Apartment elements in
PurchaseOrder to the StreetAddress element in ShippingOrder:
- Click the StreetNumber element and drag
it to the StreetAddress element.
- Click the StreetName element and drag it
to the Move transform type box. The Connection
Selection Helper window opens.
- In the Connection Selection Helper window, click Primary
Connection. The window closes and the transform type changes
to Concat.
- Click the Apartment element and drag it
to the Concat transform type box. The Connection
Selection Helper window opens.
- In the Connection Selection Helper window, click Primary
Connection.
- Click the PostalCode element in PurchaseOrder
and drag it to the PostalCode element in ShippingOrder
- Click the Province element in PurchaseOrder
and drag it to the Province element in ShippingOrder.

- To return to the main map, click the arrow icon at the upper-right
corner of the local map view.
Substring
In this example,
the OrderDate element is stored as a single date type in the purchase
order document, but in the shipping order document the same OrderDate
element is separated into the sub-elements of year, month, and day
integer types. By setting the appropriate substring transform parameters,
you can extract the year, month, and day values from the purchase
order OrderDate element and store the values in the corresponding
elements in the shipping order.
- In ShippingOrder, expand the OrderDate element.
- In PurchaseOrder, click the OrderDate element
and drag it to the Year element in ShippingOrder.
- Click the drop-down arrow in the transform type box. Expand String
Functions and then click Substring.
- Right-click the Substring transform type
box, and then click .
- In the Properties view, click the General tab.
- In the in the Delimiter field, type -.
- In the Substring index field, type 0.
- In the mapping editor, click the OrderDate element
and drag it to the Month element.
- Click the drop-down arrow in the transform type box. Expand String
Functions and then click Substring.
- In the Properties view, click the General tab.
- In the Delimiter field, type -.
- In the Substring index field, type 1.
- In the mapping editor, click the OrderDate element
and drag it to the Day element.
- Click the drop-down arrow in the transform type box. Expand String
Functions and then click Substring.
- In the Properties view, click the General tab.
- In the Delimiter field, type -.
- In the Substring index field, type 2.

Tip: You can apply the substring transforms or
concatenation transforms to elements and attributes of any type, not
just string types.
Group
In this
example, each product in the purchase order has an associated shipping
priority while in the shipping order, products are grouped by shipping
priority section elements. Using the group transform, you can group
products in the purchase order by their shipping priority and map
the resulting group to an element in the shipping order. In the group
properties, you can set the grouping parameters and the order and
sort criteria.
- In ShippingOrder, expand the OrderSections element.
- In PurchaseOrder, click the Product element
and drag it to the OrderSection element in ShippingOrder
- Click the drop-down arrow in the transform type box and click Group in
the Core Transforms section.

- Right-click the Group transform type box,
and then click .
- In the Properties view, click ShippingPriority : String in
the Product pane.
- Click Add.
- In the mapping editor, edit the Group details by clicking the
edit icon that is in the upper-right corner of the Group transform
type box. The editor opens for the OrderSection element.
- In the OrderSection details view, expand the OrderItem element.
- In the Group details view, perform the following move operations:
- Click the ID element in the Product and
drag it to the Identifier element in the OrderSection.
- Click the Price element in the Product
and drag it to the Price element in the OrderSection.
- Click the Description element in the Product
and drag it to the Name element in the OrderSection.
- Click the Quantity element in the Product
and drag it to the Quantity element in the
OrderSection.
- Click the ShippingPriority element in the
Product and drag it to the Priority element
in the OrderSection.

- To return to the man map view, click the arrow at the upper-right
of the group mapping.
Custom
In this example,
the shipping order document contains a NumberOfProducts attribute
to specify the total number of products in the order. To generate
the value for the NumberOfProducts attribute, the sum total of the
products from the purchase order must be calculated using the quantity
element. You can use an XPath expression to perform the addition operation
using a custom transformation. The result is then stored in the target
attribute, NumberOfProducts.
- Click the PurchaseOrder element and drag
it to the NumberOfProducts element in ShippingOrder.
The transform type is set to Custom XPath.

- Right-click the Custom XPath transform
type box, and then click .
- In the Properties view, click the General tab
and then click Edit.
- In the XPath Expression Builder window, type sum(Product/Quantity) and
then click OK.
