You
can map element and attribute nodes from their source document to
a target
document.
About this task
The following
mapping combinations are acceptable:
- an attribute to an attribute
- an attribute to an element
- an element to an element
- an
element to an attribute
- many nodes to one node
The
following instructions apply to the Resource perspective, but they
will also work in many other perspectives.
To create a mapping,
complete
the following steps:
Procedure
- Open your map
file in the XML mapping editor.
- Select one
or more elements or attributes in the source document. Use
the Ctrl key to select more than one element
or attribute.
- Select an element or attribute
in the target document.
- Right-click in the
source or target document and click Create
Transform. The nodes will now be mapped to
each other.
To specify the transform type, click the transform type box between
the nodes.
You can select one of the following options:
| Option |
Description |
| Move |
This type
copies
data from a source to a target. |
| Concat |
This type
creates a string concatenation which allows you to retrieve data from
two
or more entities to link them into a single result. |
| Inline map |
This
type enables the map to callout to other maps, but other maps
cannot call it. It can only be used within the current map. If the
inputs
and outputs are arrays, the inline map is implicitly iterated over
the inputs. |
| Submap |
This type
references another map. It calls or invokes a map from this or another
map
file. Choosing this transform type is most effective for reuse purposes. |
| Substring |
This type
extracts information as required. For example, the substring lastname,
firstname with a "," delimiter and a substring index of
0 returns
the value lastname. If the substring
index was
changed to 1 the output would now be firstname. |
| Group |
This
type
takes an array or collection of data and groups them into a collection
of
a collection. Essentially, it is an array containing an array. Grouping
is
done at the field level, meaning that it is done by selecting a field
of the
input collection such as "department". |
| Normalize |
This type
normalizes the input string. For example, it can be used to remove
multiple
occurrences of white space (such as space, tab, or return). |
| Custom |
This type
allows you to enter custom code or call reference code to be used
in the transform.
You can extend built-in transformation functions using custom XPath
expressions
and XSLT templates. |
Example
To remove a mapping, right-click the mapping connection
and select Delete.
Mapping
to elements with empty content
Mapping to an XML element
that has
no content at all (for example, <Person/>) is
different
than mapping to an XML element that contains character data (for example, <Person>Molly</Person>).
In the latter case, the mapping signifies that the data from the source
node
will be used as the character data for the target element. However,
in the
former case, the mapping has no effect on the XSLT that is generated.
In
a DTD, an element that has no content at all is specified using the
keyword
'EMPTY' (for example, <!ELEMENT Person EMPTY>).
In an
XML schema, it is not as straight forward. One of the syntactically
compact
ways of specifying an empty content element in an XML schema is to
define
a complex type without any simple content or complex content (for
example, <xsd:element
name="Person"> <xsd:complexType/></xsd:element>).
This is
interpreted as shorthand for complex content that restricts anyType.