This topic explains how to deal with wildcards in mappings. The wildcards xs:any and xs:anyAttribute allow you to use any elements/attributes defined in your schema file. For more information about wildcards, see the W3C Specification.
Wildcards in schema definition
The screenshot below shows that an xs:any element has been defined as a child element of the Person element (Schema view in Altova XMLSpy).
Wildcards in MapForce
When a wildcard is defined for an element and/or attribute, this wildcard node will have a (Change Selection) button next to it (see screenshot below).
Now our goal is to add another element as a separate node. Click the button to see the list of elements that you can add to the tree. Note that only elements and attributes that are globally declared in your schema can be seen in the Wildcard selections dialog box (see screenshot below).
For our example, we have selected Department. Note that wildcard elements and attributes are inserted after the node with the button. Now our component looks as follows:
You can now map to/from these nodes as usual. In a component, wildcard elements and attributes are marked with (xs:any) and (xs:anyAttribute), respectively (see screenshot above).
To remove a wildcard node, click the button and clear the corresponding check box in the Wildcard selections dialog box.
Elements/attributes from a different schema
The Wildcard selections dialog box (see above) allows you to use elements/attributes from a different schema. Clicking the Import a different schema button will give you the following options: (i) importing a schema file and (ii) generating a wrapper schema (see description below).
The Import schema option imports the external schema into the current schema assigned to the component. Note that this option overrides the existing schema on the disk. If the current schema is a remote schema that has been opened from a URL (see Adding Components from a URL) and not from the disk, the schema cannot be modified. In this case, use the Generate wrapper schema option.
Generate wrapper schema
The Generate wrapper schema option creates a new schema file called wrapper schema. The advantage of using this option is that the existing schema of the component is not modified. Instead, a new schema will be created which will include both the existing schema and the imported schema. When you select this option, you are prompted to choose where the wrapper schema should be saved. By default, the wrapper schema has the following format: somefile-wrapper.xsd.
After you save the wrapper schema, it is by default automatically assigned to the component. MapForce will also ask you whether you want to adjust the schema location so that you can reference the previous main schema. Click Yes to revert to the previous schema; otherwise, click No to have the newly created wrapper schema assigned to the component.
Wildcards vs. dynamic node names
There are situations in which elements and/or attributes in an instance are too many to be declared in the schema. Consider the following sample file:
<?xml version="1.0" encoding="UTF-8"?>
For such situations, it is recommended to use dynamic node names instead of wildcards. For more information, see Mapping Node Names.