MapForce Offers Dynamic Access to Node Names


There are situations, especially when encountering loosely structured data, where you may want to map and transform structural components of a data stream along with content. MapForce 2017 includes a new feature to dynamically access node names of XML elements, attributes, or text file columns such as the contents of CSV files, to target components.

Dynamic access to node names allows creation on the fly of target elements and attributes whose names do not need to be known beforehand or specifically identified in the data mapping. This feature lets you create much more generic, flexible, and reusable mappings that require less manual intervention if data models evolve.

News about Dynamic Access to Node Names in MapForce 2017

Here is an example of a very common style of CSV file where data fields are not identified by column names, but by labels in a neighboring cell within the row:

Typical input data in CSV format

The records in this example are not even structured consistently, since one record includes a suffix after the last name and another record includes a middle initial.

A likely data mapping requirement for files like this is to map the cells in column A as XML element names and the cells in column B as values for each corresponding element. This is now easily accomplished with dynamic mapping of node names. Let’s look at how it’s done.

Dynamic Access to Node Names of XML Elements

We’ll start by creating a very simple XML Schema for the mapping target that uses the <xs:any> element to define a complex <Employee> element that can have any  child elements. Here it is in XMLSpy Schema view:

XMLSpy Schema View of Data Mapping Target

We start the mapping by dropping in the CSV file and using a group function that will create a new <Employee> element each time FirstName appears in Column A of the input.

MaForce data mapping showing a group function

Next we drop in the target XML Schema, and right-click the <Employee> element:

MapForce context menu to select Dynamic Accessic

This opens the context menu, showing new options added in MapForce v2017. We will choose the option Show Child Elements with Dynamic Name, which opens a dialog where we will select text as the data type for child elements. This exposes the node name and content for child elements of <Employee> as shown here:

MapForce data mapping target with dynamic node name access

Now it’s a simple process to map from Field1 (column A of the CSV file) to the child element node names and from Field2 (column B) to the element content. Here is the final data mapping:

MapForce Data Mapping with Dynamic Access to Node Names

The function group-starting-with at the top creates a new <Employee> element every time “FirstName” is encountered in the input file. Then, for each row, entries in column A generate child element names and entries in column B become values for each child element.

Output for the mapping above looks like this:

MapForce dynamic access data mapping output

The advantage of a data mapping that uses dynamic access to the names of nodes is you do not have to do a comprehensive survey of the input data to identify and map every possible element name.

Consider a common production scenario where you accept multiple input files from one or more external sources and automate mapping execution with MapForce Server and FlowForce Server. If an input file arrives that suddenly contains an unexpected child element – OfficeLocation or MailStop, for instance – the data will not be lost.

Dynamic Access to Node Names of XML Attributes

You can also dynamically map the names of XML attributes, with the same ability to create target elements and attributes on the fly without necessarily identifying them all ahead of time.

MapForce 2017 with dynamic node name mapping, enhanced XBRL and database support, and many other new features, is available for download here as a 30-day trial. V2017 is also a free upgrade for existing users with valid SMP.

Tags: , , ,