Difference between revisions of "XML Data mapper"

From GreenVulcano Wiki
Jump to: navigation, search
(Functions)
Line 56: Line 56:
 
*Numarg: the number of function arguments.
 
*Numarg: the number of function arguments.
 
*Prefix: the namespace prefix used by the function (example: java).
 
*Prefix: the namespace prefix used by the function (example: java).
*Namespace: the namespace of the function (eg.: http://xml.apache.org/xalan/java)
+
*Namespace: the namespace of the function (eg.: <nowiki>http://xml.apache.org/xalan/java</nowiki>)
  
 
===Additional nodes===
 
===Additional nodes===

Revision as of 16:11, 7 February 2012

Introduction

XML Data mapper module allows users to implement a data transformation from one format defined by a source xsd to a format defined by a target xsd, and to create xsl documents in a data transformation defined in VulCon. The use of graphics speeds up the process of defining the mapping of data, and gives it a simple and efficient graphical representation.

Create a data transformation

The steps required to create a graphical form of data transformation are:

  • Access the VulCon Core view and expand the GVDataTransformation node
  • Click on Transformations item with right mouse button and choose in the drop-down list
Transformations --> Create XSLT Transformation
  • Using the appearing wizard, insert the data transformation definition parameters:
    • Transformation Name: a configuration file with .gvxdt extension and a xsl transformation file with .xsl extension will be created with the name choosen in this field
    • Data Source: the datasource name that indicates the repository where files will be deposited
    • Path XSL: internal del datasource path in which the xsl file will be generated
    • XSD Input: xsd file name defining the source format
    • root XSD Input: source xsd file root element name from which start the data transformation operation. Xsd files suggested by the drop-down list are stored in the /conf/xsds folder
    • XSD Output: xsd file name defining the target format
    • root XSD Output: target xsd file root element name from which start the data transformation operation. Xsd files suggested by the drop-down list are stored in the /conf/xsds folder
  • Click the wizard Finish button: in Graphic Editor VulCon perspective will appear the Data mapper graphic editor in which in possible to define the transformation details
  • Generate the resultant xsl file.

Data mapper graphic editor

Data Mapper

In Data mapper graphic editor are visible the representations for input and output formats.Items followed by '=' character are attributes, while those enclosed in angle brackets '<>' are nodes of the xml data. Is it possible to compress or expand simply by clicking on '+' or '-' symbols on the left of each node name. The right pane contains the palettes used for the definition of the data mapping. The Select button allows the selection of the xsd nodes interested for the transformation. The Create link button allows to define links:

  • between a source and a target element;
  • between a source element and a parameter of a function;
  • between the output of a function and a parameter of another function;
  • between the output of a function and a target element.

In the folders below that buttons, it is possible to access the functions used for data-mapping grouped by topic.

Access

To access the editor you can:

  • double click a .gxdt file previously created in the Project view;
  • otherwise, right-clicking on the transformation in the core view and then choosing the 'Open mapping <transformation name>' item.

Links

A link is a relation between the node in the source format and its counterpart in the target format. Clicking the Create link button in the Palette pane, link mode is enabled. In this mode is possible creating a new connection simply clicking on a node in the source xsd format, and dragging it on a target node. Once defined a new connection in the graphic area, properties of the selected object are shown in Properties area. 'Match' property allows the definition of the selected mapping generation mode:

  • template: a template node will be created e called into the mapping;
  • for-each: a for-each node will be created to generate all defined mapping.

Functions

Folders on the right of Graphic Editor contain the most largely used XSLT and xpath functions, organized by topic.
To use a function is sufficient to select it in the appropriate folder and then to click where is preferred in the editor. For those functions which have a variable number of parameters, such as the 'concat' operation, a dedicated pop-up will open. Once done this steps, a graphical representation of the new function will be present in the graphical area.

DTE Function

At this point you need to create all links to define the input parameters and the one to define the element that will assume the output value of the function.
To give a constant value to a function parameter you must right-click on its graphical representation and then insert the value. To modify a parameter value simply set it in the corresponding property in the lower Property editor.
If the desired function is not present inside function folders, it is possible to define it choosing from Custom folder. To do this you must enter values ​​in the following fields:

  • Name: the name of the function to create (eg.: java:it.greenvulcano.gvesb.datahandling.utils.GenericRetriever.getData).
  • Label: the label displayed on the editor (eg.: getId).
  • Numarg: the number of function arguments.
  • Prefix: the namespace prefix used by the function (example: java).
  • Namespace: the namespace of the function (eg.: http://xml.apache.org/xalan/java)

Additional nodes

Some XSL transformations need to create nodes by duplicating the base node. To realize this operation, simply select the base node with the right mouse button and then a new duplicate node will be created. An ordinal value will be reported next to the new selected node. A node with an 'n' ordinal value represents the only n-th instance of that node. A node without ordinal values represents all the nodes of that type.

Xsl file generation

To generate the xsl file you must select the 'xsl Save File' menu item icon on the editor tool bar. The file will be created in the subsequently selected directory.

{{#w4grb_rate:}} <w4grb_ratinglist latestvotes items="5" nosort/>