Data Mapping Files with XML Mixed Content


As more specialized data is adapted for delivery on demand to mobile devices with smaller screens, documents with complex structures can be a challenge. Fortunately, MapForce, Altova’s graphical data mapping, conversion, and integration tool, has special features to accelerate data integration projects of all sizes.

For example, richly-formatted documents may include XML mixed content, a complex datatype that permits an XML element to contain text, attributes, and other child elements. Common instances of XML mixed content include blocks of text with tags for bold or italic fonts, or tags that select terms for indexing or other special treatment. Documents with XML mixed content can be difficult to include in a data integration project, since they appear to be free-form and unpredictable, with child elements that occur in any order or even multiple times within the parent.

Mapping_mixed_content

The sample files installed with MapForce and the MapForce online help system are good places to look for tips when you encounter an unfamiliar data-mapping requirement.

The images below show portions of two files in the MapForce Examples folder that illustrate XML mixed content, with elements that contain text and additional child elements.

Capture text 1

Capture text 2

The file in the first image uses familiar XML tags for paragraph and font markup. The para element is XML mixed content because it contains text and child elements for terms that are intended to be bold and italic. The second example uses a more specialized set of elements, where the intended presentation is not clear for the terms tagged as Trademark and Keyword inside the SubSection element.

Data Mapping XML Mixed Content

You can map between two XML Schemas with mixed content in MapForce by drawing connecting lines between the input and output. As shown below, when we connect the source element SubSection, which contains XML mixed content, MapForce displays a helpful suggestion to assist with accurate mapping design:

Mapping plus dialog

Clicking Yes in the dialog instructs MapForce to automatically connect the text portions between the source and destination:

Capture mapping after dialog

The dotted line connection indicates XML mixed content mapping, and the text and child elements that compose the mixed content are all mapped individually. The last step to complete the mapping is simply to map Trademark and Keyword from the source to the desired elements in the output component.

Capture mapping ShortApplicationInfoSample

The tags Trademark and Keyword are formatted with bold and italic font tags, as seen in the output file.

Capture mixed content mapping output

The data mapping illustrated here is included as ShortApplicationInfo.mfd in the MapForce Examples folder.

Map XML Mixed Content to Simple Content

If you need to create a more simplified version of a document that has XML mixed content, you can also map the mixed content to a simple element. The screenshot below shows the same input file containing XML mixed content, but the Description element of the output component is a simple string data type. In this mapping the SubSection element is mapped directly to Description in the output component.

Capture mixed to simple mapping

When the mapping is executed, all text in the source SubSection element, including text in child elements, is mapped to the destination without any child element tags.

output of shortinfo simple map

After a MapForce data mapping is designed and tested, it can be executed to transform data immediately, or it can be saved for execution by MapForce Server to automate business processes that require repetitive transformations.

Altova MapForce is an award-winning any-to-any graphical data mapping, conversion, and integration tool that maps data between any combination of XML, database, EDI, XBRL, flat file, Excel, JSON, and/or Web service. This post described just one example of many specialized data mapping features available at a fraction of the cost of traditional big-iron data integration products, making MapForce the ideal data mapping, integration and transformation tool for today’s fast-moving workgroups and enterprises.

Download a fully-functional free trial to see for yourself!

 

Tags: , ,