Altova MapForce 2024 Enterprise Edition

Most of the time when you create a mapping with MapForce, the goal is to read values from a source and write values to a target. However, there might be cases when you want to access not only the node values from the source, but also the node names. For example, you might want to create a mapping which reads the element or attribute names (not values) from a source XML and converts them to element or attribute values (not names) in a target XML.


Consider the following example: you have an XML file that contains a list of products. Each product has the following format:








Your goal is to convert information about each product into name-value pairs, for example:


    <attribute name="id" value="1" />
    <attribute name="color" value="red" />
    <attribute name="size" value="10" />


For such scenarios, you would need access to the node name from the mapping. With dynamic access to node names, you can perform data conversions such as the one above.


Note:You can also perform the transformation above by using the node-name and static-node-name core library functions. However, in this case, you need to know exactly what element names you expect from the source, and you need to connect every single such element manually to the target. Also, these functions might not be sufficient, for example, when you need to filter or group nodes by name, or when you need to manipulate the data type of the node from the mapping.


Accessing node names dynamically is possible not only when you need to read node names, but also when you need to write them. In a standard mapping, the name of attributes or elements in a target is always known before the mapping runs; it comes from the underlying schema of the component. With dynamic node names, however, you can create new attributes or elements whose name is not known before the mapping runs. Specifically, the name of the attribute or element is supplied by the mapping itself, from any source supported by MapForce.


For dynamic access to a node's children elements or attributes to be possible, the node must actually have children elements or attributes, and it must not be the XML root node.


Dynamic node names are supported when you map to or from the following component types:





* Requires MapForce Professional or Enterprise Edition.


Note:In case of CSV/FLF, dynamic access implies access to "fields" instead of "nodes", since CSV/FLF structures do not have "nodes".


When the mapping target is a CSV or FLF (fixed-length field) file, the fields must be defined in the component settings (and it is not possible to change the name, order, or number of the target fields). Unlike XML, the format of text files is fixed, so only the actual field value can be manipulated, not the field name, number or order.



Dynamic node names are supported in any of the following mapping languages: Built-In*, XSLT 2.0, XSLT 3.0, XQuery*, C#*, C++*, Java*.


* These languages require MapForce Professional or Enterprise Edition.


For information about how dynamic node names work, see Getting Access to Node Names. For a step-by-step mapping example, see Example: Map Element Names to Attribute Values.

© 2018-2024 Altova GmbH