The Mappings tab allows you to create mappings between XML schema or DTD elements or attributes and database columns, expressions or constants. The Mappings tab consists of three main panes and one optional pane:
XML Schema/DTD pane -- Displays elements and attributes in an XML Schema/DTD specified in the Mapper wizard.
Database pane -- Displays selected tables from a relational database specified in the Mapper wizard.
XML Mappings pane -- Displays mappings that have been created.
Column Information pane -- Appears in the Database pane after clicking View Column Information in the Database toolbar.
This topic also explains how to access the Mappings tab.
You can create mappings in the following ways:
To map an element or attribute to a database column, either:
- select an element or attribute in the left pane and a database column in the right pane, then click Map Column in the Schema/DTD Toolbar
or,
- click and hold down the mouse over an element or attribute in the left
pane, move the mouse over to the database column in the right pane, then
release it to create a mapping.
To map an element or attribute to an expression, select an element in the left pane then click Map Expression in the Schema/DTD Toolbar.
To map an element or attribute to a constant, select an element or attribute in the left pane then click Map Constant in the Schema/DTD Toolbar. You can map a constant to the empty string by leaving the Enter Constant Value dialog blank.
To map a column to an XML expression, select a column in the right pane then click Map database column to expression.
When you create a mapping for a node, it is displayed in the XML Mappings pane, and a blue line connects the mapped node and database column. If the mapping is appropriate to use both in marshalling data to XML and unmarshalling data to a database, it appears on both the Mappings for Marshalling and Mappings for Unmarshalling tabs.
You can delete mappings in the following ways:
To delete all mappings for a displayed schema/DTD, select the root node in the XML tree and click Unmap Subtree.
To delete the mapping for a single element or
attribute, select the node in the XML tree and click Unmap Node.
Or, in the XML Mappings pane, make sure the Views menu is set to "Show
Mappings for Node" then select the node and click Delete Mapping
When you create a mapping, by default the Mappings tab displays the mapping line for the currently selected node or column. You can also display mapping lines for all mappings or for a subtree.
Select the top node in the XML Schema pane.
From the right mouse button menu, choose Reveal All Mappings for Subtree.
This pane displays XML Schema or DTD elements and allows you to map XML elements to columns, expressions and constants. By default, XML nodes do not display any namespace information. Use the XML Schema tab in the Project Properties dialog to view namespaces in the XML Schema/DTD pane.
In the Mappings tab, you can also:
add XML nodes to a mapping file without mapping them to a column, expression or constant using Add Node to Mapping File.
create
a hidden attribute in the mapping file using
Add
Hidden Attribute. The attribute appears
in the mapping file and can be used when marshalling but does not appear
in the XML output file.
For large schemas or DTDs, you can control which elements you view by
clicking
Add/Remove Global
Elements in the Schema/DTD pane and selecting elements for display
in the Select XML Elements dialog.
The schema/DTD tree uses the following conventions:
|
|
An element that can be mapped |
|
|
An element that has been mapped |
|
|
An element that has been mapped and used as a key for combining XML output nodes. |
|
|
An attribute that can be mapped |
|
|
An attribute that has been mapped |
|
|
An attribute that has been mapped and used as a key for combining XML output nodes. |
|
|
A hidden attribute that can be mapped |
|
|
A hidden attribute that has been mapped |
|
|
A hidden attribute that has been mapped and used as a key for combining XML output nodes. |
|
|
An element or attribute that cannot be mapped |
|
|
An element that has been mapped where the element name in bold type means that the Combined Node property has also been set on the element in the XML Structure tab. |
Shows the tables that you selected in the New Project wizard, generated from an XML schema in the New Project wizard, or selected using the Add/Remove Database Tables dialog. You can add or remove tables by clicking Add/Remove Tables in the main toolbar.
Table columns are displayed in the Database pane in the order that is used in the database. If you have many columns and need to locate them by name, you can display the columns alphabetically. Select a table and choose Sort Table Columns from the right mouse button menu.
When the Mapper loads database information, it also loads information about primary keys for each table and columns with auto-increment identifiers. In the database tree, columns in bold represent primary keys in the database.
To view detailed column information:
Select a column in the tree.
Click View Column Information.
The Column Information pane is displayed to the right of the Database pane.
The Database Pane uses the following conventions:
|
|
A SQL Query folder. The database columns that appear below this folder
have been retrieved using a SQL query entered during project creation
or using |
|
|
A table retrieved from the database |
|
|
A user-defined table |
|
|
A table alias |
|
|
A database column that can be mapped |
|
|
A database column that has been mapped |
|
|
A database column that is a primary key in the database |
This is not visible by default. To view the table:
In the Database toolbar, click View Column Information.
It contains meta data for the column, including the data type and size.
The XML Mappings pane consists of two tabs: Mappings for Marshalling and Mappings for Unmarshalling. When you have made a mapping that applies to both marshalling and unmarshalling (mapping an element to a column for example), it appears on both tabs. If you map a database column to an XML expression, for example, it appears on the Mappings for Unmarshalling tab. Both tabs by default show the mappings for a selected node's subtree in the XML Schema/DTD pane. You can also view mappings for a single node.
Single Node View
You can perform the following operations on a single node.
Delete a mapping by first selecting the node, then clicking Delete Mapping.
Set the priority of mappings when you have mapped a single node to more than one column.
If you have mapped a single node to more than one column, you see both mappings in the table. You can set the priority of the mappings using the up and down buttons in the toolbar. This priority is used in cases where the mapping file is used for marshalling and only one column can be marshalled. If the mapping file is used in unmarshalling, the Allora mapping engine is able to update multiple columns in the database.
Node Tree View
To view all the mappings for a node tree:
In the XML Schema/DTD pane, select the top element in the tree.
In the XML Mappings pane, from the Views menu , choose Show Mappings for Subtree.
Sort rows alphanumerically in the XML mappings table by clicking the column heading you want to use for sorting.
Note: When you show mappings for a subtree, you disable the ability to view the line that shows an element mapped to a database column.
The Mappings tab is available when displaying a mapping file in Design View (the default). Double-click a mapping file in the Project Explorer to display Mappings, XML Structure, Table Properties, Table Relations and Predicates tabs.
Use the tabs along the bottom of the Mapper window to switch between open files.