Tuesday, July 31, 2012

WPS: XSLT Maps in detail in V7.5


Introduction :
An XML map exists to transform a source XML document into a target XML document.
Note : The XML document that is produced needs to be complete in that it contains all the expected data and the document also needs to be valid and match its corresponding schema.

 
 
Maps are generally created within a Mediation Module project for use within a particular Mediation Flow or within a Module project for use within a particular Business Process Flow. Within a Mediation Flow, map files are created using the XSL Transformation primitive. Within a Business Process Flow, map files are created using the Data Map basic action.

When creating maps within a Mediation Flow, a mapping root is required. The mapping root determines which part of the primitive input message is used as the mapping input and which part of the primitive output message is used as the mapping output. 
In the case of mediation flows, the messages are SMO messages that are broken up as follows:
  • Context
  • Headers
  • Body


Mapping refinements :

                   Once you create an association between the source and target, the association is called a transformation or a mapping. Each mapping can have a single refinement to indicate what type of mapping it is. This section describes the refinements.


1. Move :  Move is the most basic refinement. It takes a simple or complex field on the source side and moves it unchanged from the source to the target.
2. Convert : The Convert refinement is used to do simple conversions between simple data types. An example usage of the Convert refinement is to covert a Boolean value (true or false) to an Int value (1 or 0). Another example usage would be to extract a specific type of value from a string.
3. Assign : The Assign refinement is used when you want to assign a constant value to a target element or attribute. Assign is only available for assigning a value to simple type fields, such as string and int. 

4. Local Map: A Local map is a tool for organizing a mapping file. It allows you to nest mappings for complex types so that the top level mapping does not become cluttered with too much detail. Nothing will move from the source to the target until you go inside the Local map and create mappings using refinements.  Local map is used as a container mapping to localize nested mappings (such as Move), which perform the actual transformations.
A Local map contains a single input field and a single output field. In cases where multiple input fields are required, a Merge mapping replaces a Local mapping, but it behaves similarly.
Once you have created a Local map between a source and target, you can double-click the Local map refinement to navigate into the map. Once inside the Local map you can create the child mappings. While inside a Local map, you will notice that you can navigate out of the Local map, back to the parent mapping by using the "Up a level" icon in the top right corner of the mapping area. While inside a Local map, you will notice that a gray background is used to indicate that you are working within a nested mapping.
A Local map is not reusable. In cases where you are mapping source and target types that you know will be mapped the same way in other maps, consider using a Submap that you can reuse and share among many mapping files 
5. Merge : A Merge refinement is similar to a Local map in the sense that it is a container for nesting other mappings. Unlike a Local map, Merge supports multiple source inputs. This allows you to take data from two different source fields and merge them into a single target field.

6. Sub Maps : A Submap refinement is a mapping between two specific types that is stored in a separate file. A Submap is a root mapping in a regular map file, which you can reference from any other map file making it ideal for reuse. Since Submaps are designed for re-use, we recommend that you store Submaps in libraries where they can be easily shared and reused amongst dependent modules.
 Note: In some cases, you may find that you cannot create a Submap for a desired type because the type is not defined in an XSD file. This can be the case if the type is defined in a WSDL file. The Submap creation wizard will not allow you to create a Submap with a non XSD defined type as the input or output. In this case, you can refactor the type out of the WSDL file by doing the following:
  1. In the Business Integration view, locate the desired type in the Data Types category of the module or referenced library project.
  2. Right-click the type and select Refactor > Extract In-lined Business Objects.
After extracting the desired type, you can create a Submap using the extracted type as an input or output. The Submap refinement is not available when working with local elements or anonymous types. In the case of local elements or anonymous types, reusable mappings are not an option at this time.
Tip: In cases where there are many maps and submaps within a module or library, you can use the Data Map Catalog to view a detailed summary of available maps. To view the Data Map Catalog, select a project in the Business Integration view, right-click the project and select Open Data Map Catalog.
7. Built-in Functions : There are a few common built-in functions that you can use within the Mapping Editor, such as Concat, Normalize, and Substring. In addition to these, there are over 60 XPath and EXSLT Java™ functions that you can easily use to transform data.
we have set of functions available in XML map :
Core Transformation
String Functions
Date and Time Functions
Qname Functions
List Functions
Custom Transforms
Node Functions
Diagnostic Functions
Boolean Functions
Math Functions

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.