Creating the mapping for an SQL statement DAD file
An SQL statement mapping document access definition (DAD) file is created with an SQL statement (SELECT or FULLSELECT) to a DTD mapping. The DAD can be used to compose an XML document from an SQL query.
The following instructions were written for the Resource perspective, but they will also work in many other perspectives.
To ensure that a valid SQL statement mapping DAD is generated, all text nodes in the XML file must be mapped.
Follow these steps to map your SQL statement to the XML file:
- Open your mapping in the RDB to XML mapping editor.
- Expand the XML nodes in the Tables and XML panes.
- Select a column from the Tables pane.
- Select a column element or attribute in the XML pane that you want to map to.
- Right-click and select Create Mapping.
One column can be mapped to many XML nodes, but each XML node can only be mapped to by one column.
You can use the Match Mapping option to map columns and nodes with common names. When you select the SQL statement and an XML node, the tool will map the selected objects, then it will attempt to map the columns in the statement to the children of the selected XML node based on common names. The process continues until all of the columns and descendant XML nodes with common names are mapped.
To map columns and nodes with the same name:
- Open your mapping in the RDB to XML mapping editor.
- Select the SQL statement in the Tables pane and the node to be mapped. They do not have to have a common name, but they will be mapped.
- Select Mapping > Match Mapping
To remove a mapping, right-click the mapping in the Outline view and select Remove Mapping.
Once you have created the mapping, you can create a SQL statement mapping DAD file by selecting Mapping > Generate DAD and completing the wizard.
Selecting options
Choice support enables you to dynamically select or map any member of a choice in the XML pane view during a mapping session. You are only allowed to map one member of a choice; consequently, selecting a new member of a choice automatically removes any existing mappings related to the previously selected member.
To create a mapping using a choice member currently not shown in the XML pane:
- Open your mapping in the RDB to XML mapping editor.
- Select the choice member that is currently shown in the XML pane. An arrow will appear next to it. Click the arrow and select the appropriate member from the drop down menu.
- Create the mapping. Any mappings associated with the previously selected member is automatically removed.
For example:
- You select Person.dtd as your target file, which contains a choice with the two members: Province and State.
- When you open your mapping session, Province is in the XML pane. You create a mapping between a column called Location in the Source view and Province in the XML pane.
- You then click Province in the XML pane and select State from the drop down menu. Your previous mapping between Location and Province is now gone. You can now create a new mapping between Location and State.
Parent topic
Editing an RDB to XML mapping
Related concepts
Relational database to XML mapping (visual DAD builder)
Related tasks
Specifying the source tables and target DTD file
Editing an RDB to XML mapping
Creating the mapping for an RDB_node DAD file
Creating join conditions