Mapping mixed content

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Designing Mappings > Connection Types > Source-driven connections >

Mapping mixed content

The files used in the following example (Tut-OrgChart.mfd, Tut-OrgChart.mfd.xml, Tut-OrgChart.mfd.xsd, Tut-Person.xsd) are available in the ...\MapForceExamples\Tutorial\ folder.

 

Source XML instance

A portion of the Tut-OrgChart.xml file used in this section is shown below. Our area of concern is the mixed content element "para", along with its child nodes "bold" and "italic".

 

The para element also contains a Processing Instruction (<?sort alpha-ascending?>) as well as Comment text (<!--Company details... -->) which can also be mapped, as shown below.

mixed-1

Note the sequence of the text and bold/italic nodes in the XML instance file:

 

<para> The company...

<bold>Vereno</bold>in 1995 ...

<italic>multi-core...</italic>February 1999

 

<bold>Nano-grid.</bold>The company ...

<italic>offshore...</italic>to drive...

</para>

 

Initial mapping

The initial state of the mapping when you open Tut-Orgchart.mfd is shown below.

mixed-2

 

Output of above mapping

The result of the initial mapping is shown below: Organization Chart as well as the individual office names have been output.

mixed-3

 

Mapping the para element

The image below shows an example of mixed content mapping. The para element is of mixed content, and the connector is shown as a dotted line to highlight this. The text() node contains the textual data and needs to be mapped for the text to appear in the target component.

mixed-4

To annotate (add a label to) any connection, right-click it and select Properties (see Annotating Connections ).

 

The image below shows the content model of the Description element (Desc) of the Tut-OrgChart.xsd schema file. This definition is identical in both the source and target schemas used in this example.

alp-mix1

Note the following properties of the para element in the Content model:

 

para is a complexType with mixed="true", of type "TextType"
bold and italic elements are both of type "xs:string", they have not been defined as recursive in this example, i.e. neither bold, nor italic are of type "TextType"
bold and italic elements can appear any number of times in any sequence within para
any number of text nodes can appear within the para element, interspersed by any number of bold and italic elements.

 

To create mixed content connections between items:

1.Select the menu option Connection | Auto Connect Matching Children to activate this option, if it is not currently activated.
2.Connect the para item in the source schema, with the para item in the target schema. A message appears, asking if you would like MapForce to define the connectors as source driven.

dlg_mixed_content_notice

3.Click Yes to create a mixed content connection.

 

Note:Para is of mixed content, and makes the message appear at this point. The mixed-content message also appears if you only map the para items directly, without having the autoconnect option activated.

 

All child items of para have been connected. The connector joining the para items is displayed as a dotted line, to show that it is of type mixed content.

4.Click the Output tab to see the result of the mapping.

mixed-5

5.Click the word Wrap icon ic-wrap in the Output tab icon bar, to view the complete text in the Output window.

mixed-6

The mixed content text of each office description has been mapped correctly; the text, as well as the bold and italic tag content, have been mapped as they appear in the XML source file.

6.Switch back to the Mapping view.

 

To remove text nodes from mixed content items:

1.Click the text() node connector and press Del. to delete it.

mixed-del

2.Click the Output tab to see the result of the mapping.

mixed-8

 

Result:

all text nodes of the para element have been removed.
mapped bold and italic text content remain
the bold and italic item sequence still follows that of the source XML file.

 

 

To map the Processing Instructions and Comments:

1.Right-click the mixed content connection, and select Properties.
2.Under Source-Drive (Mixed content), select the Map Processing Instructions and Map Comments check boxes.

© 2019 Altova GmbH