Mapping Data

At its simplest, mapping creates an association between a database column and an element or attribute in an XML DTD that moves data from one to the other. In a query, data is retrieved from the Repository and added to the output XML document, while in an update, data from the XML document modifies the Repository.

Mappings for queries are somewhat more complicated because the output data may not come from the Repository directly. These values may be generated by a User Defined Function extension (UDF) which may generate results based on values from multiple tables, or they may be multiple XML nodes. These values may also be derived from CGI variables or from the user context.

Note that when mapping a query, the Backend column is on the left side of the mapper and the XML column is on the right, while when mapping an update, the XML column is on the left side of the mapper and the Backend column is on the right.

To map a database column to an XML node, select the column and the node, then click the [Add] button. The mapper adds the two objects to the first available row in the mapper. You can also map the column and node by dragging each into a cell in the same row of the mapper. A third option is to drag a column objects into a cell of the Backend Column in the Mappings table and manually enter a node name in the XML column.

Use the same process to map a CGI variable or user context variable.

If you map a UDF, you must specify values for its parameters. If you add a UDF to a mapping by dragging it into a cell, the Workbench automatically displays the Function Properties dialog, where you can specify the values. Otherwise, double-click on the UDF in its cell to display the Function Properties dialog.

Assigning Conditions to a Mapping

To assign a condition to a mapping:

  1. In the row of the mapping to which you want to add the condition, click the Condition button , then click the browse button .

    The Percussion Workbench displays the Conditional Property dialog.

  2. Click in the Variable column and use the Value Selector to choose the Variable you want to evaluate.
  3. In the OP column, choose the operator for the condition. Options include:
    • =
    • !=
    • <
    • <=
    • >
    • >=
    • IS NULL
    • IS NOT NULL
    • BETWEEN
    • NOT BETWEEN
    • IN
    • NOT IN
    • LIKE
    • NOT LIKE
  4. Click in the Value column and use the Value Selector to choose the value for the condition.
  5. If you want to add multiple conditions, you must specify a Boolean operator in the bool column to define how the conditions are linked. Options are AND and OR. Standard precedence rules apply (AND takes precedence over OR.) Note also that conditions cannot be grouped in this dialog; in other words, you cannot create complex conditions such as ((A or B) and C) or ((D and E) or F or G).
  6. Repeat steps 2 through 5 for each condition you want to assign to the mapping. (The boolean operator can be omitted from the last condition.)
  7. Click the [OK] button to save the conditions.