The wildcards xs:any (and xs:anyAttribute) allow you to use any elements/attributes from schemas. The screenshot shows the "any" element in the Schema view of XMLSpy.
In MapForce, a Change Selection ( ) button appears to the right of the xs:any element (or xs:anyAttribute).
When clicked, the Change Selection button opens the "Wildcard selections" dialog box. The entries in this list show the global elements and attributes declared in the current schema.
Clicking one or more of the check boxes and confirming with OK, inserts that element/attribute (and any other child nodes) into the component. The wildcard elements or attributes are inserted immediately after the node whose Change Selection ( ) button was clicked.
You can now map to/from these nodes as with any other element.
On a component, the wildcard elements or attributes can be recognized by the (xs:any) text appended to their name.
To remove a wildcard element, click the Change Selection ( ) button, and then deselect it from the "Wildcard selections" dialog box.
Wildcards and dynamic node names
Mapping data to or from wildcards is generally suitable where all possible elements or attributes that appear in the XML instance are declared by the component's XML schema (or can be imported from external schemas). However, there may be situations where elements or attributes appearing in an instance are too many to be declared in the schema. Consider the following instance where the number of child elements of <message> is arbitrary:
<?xml version="1.0" encoding="UTF-8"?>
For such situations, use dynamic access to node names (see Mapping Node Names) instead of wildcards.
Adding elements from a different schema as wildcards
Elements from a schema other than the one assigned to the component can also be used as wildcards. To make such elements visible on the component, click the Import a different schema button on the "Wildcard selections" dialog box. This opens a new dialog box where you have two options:
|2.||Generate wrapper schema|
For example, the image below illustrates what happens if you attempt to import an external schema called HasExpenses.xsd into a current schema assigned to a component.
The Import schema option imports the external schema into the current schema assigned to the component. Be aware that this option overrides the existing schema of the component on the disk. If the current schema is a remote schema that was opened from a URL (see Adding Components from a URL) and not from the disk, it cannot be modified. In this case, use the Generate wrapper schema option.
The Generate wrapper schema option creates a new schema file called a "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 (that is, the wrapper schema) which will include both the existing schema and the schema to be imported. When you select this option, you are prompted to choose where the wrapper schema should be saved. By default, the wrapper schema has a name in the form somefile-wrapper.xsd. After you save the wrapper schema, it is by default automatically assigned to the component, and a dialog box prompts you:
Click Yes to revert to the previous schema; otherwise click No to keep the newly created wrapper schema assigned to the component.
© 2019 Altova GmbH