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. |
Inline 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 File name field, type MyOrderMapping.map,
and click Next.
- In the Root inputs pane, click Add.
- Select XML Schema from the Files of type drop-down
list, and click Browse. Expand and select PurchaseOrder.xsd,
and click OK.
- Choose PurchaseOrder as the source root element,
and click OK.
- In the Root outputs pane, click Add.
- Select XML Schema from the Files of type drop-down
list, and click Browse. Expand and select ShippingOrder.xsd,
and click OK.
- Choose ShippingOrder as the target root element
and click OK.
- Click Next.
- To select a sample XML input file, click Add. Choose
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 value of the
PurchaseOrderReference attribute in the ShippingOrder document.
- In the XML mapping editor, click the OrderID element
from PurchaseOrder and drag it to the PurchaseOrderReference attribute
in ShippingOrder.

Concatenation
In this example the
first, middle, and last name elements of the PurhchaseOrder document are concatenated
into a single value for the CustomerName element in the ShippingOrder document.
- In the XML mapping editor, click the FirstName element
from PurchaseOrder and drag it to the CustomerName element
in ShippingOrder.
- Click the LastName element from PurchaseOrder and
drag it to the transform type box between PurchaseOrder and ShippingOrder.
Note: After
you drag a second element to the transform type box, the transform type should
automatically change to Concat.
- Click the MiddleInitial element from PurchaseOrder
and drag it to the transform type box.

- Right-click the transform type box, and select Show in Properties.
- To change the order of concatenation values, click the Order tab
in the Properties view. Click MiddleInitial, and click
the up arrow Reorder icon.
Note: You can customize
concatenation options for ordering, delimiters, prefix, and postfix.
Inline map
In this example both
source and target documents contain the complex element ShippingAddress.
- In the XML mapping editor, click the ShippingAddress element
from PurchaseOrder and drag it to the ShippingAddress element
in ShippingOrder.

- Click the edit icon at the top right corner of the transform type box.
Note: You
must map each ShippingAddress sub-element in the Inline map details view.
- In the Inline map details view, perform the following mapping transforms:
- Click the StreetNumber element and drag it to the StreetAddress element.
- Click the StreetName element and drag it to the
transform type box. Repeat this for the Apartment element.
- Click the PostalCode element and drag it to the PostalCode element
on the right.
- Click the Province element and drag it to the Province element
on the right.

- To return to the main map, click the arrow icon at the top right of the
inline map details page.
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.
- Click the OrderDate element from PurchaseOrder
and drag it to the Year element in ShippingOrder.
- Click the drop-down arrow in the transform type box, and select Substring from
the list.
- Right-click the transform type box, and select Show in Properties.
- In the Properties view, in the Delimiter field,
type -.
- In the Substring index field, type 0.
- Click the OrderDate element and drag it to the Month element.
- Change the transform type to Substring.
- In the Properties view, in the Delimiter field,
type -.
- In the Substring index field, type 1.
- Click the OrderDate element and drag it to the Day element.
- Change the transform type to Substring.
- In the Properties view, in the Delimiter field,
type -.
- In the Substring index field, type 2.

Note: 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.
- Click the Product element from PurhaseOrder and
drag it to the OrderSection element in ShippingOrder
- Click the transform type box and select Group.

- Right-click the transform type box, and click Show in Properties.
- In the Properties view, click ShippingPriority in
the left pane.
- Click Add.
- To view group details, click the arrow at the top right of the transform
type box.
- In the group details view, perform the following move operations:
- Move the ID element to the Identifier element.
- Move the Price element to the Price element
on the right.
- Move the Description element to the Name element.
- Move the Quantity element to the Quantity element
on the right.
- Move the ShippingPriority element to the Priority element.
- To return to the man map view, click the arrow at the top right of the
group details page.
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.
- Click the transform type box, and select Custom.

- Right-click the transform type box, and select Show in Properties.
- In the Properties view, you can create an XPath expression. For this example,
type sum(Product/Quantity).
