
Chapter 6 Exchanging data with databases supporting XML
Mapping XML objects to PDM objects
There are several ways to map XML objects to PDM objects:
- Using the XML Builder Wizard (See following procedure)
- Generating an XML model from a PDM
- Generating a PDM from an XML model
- Manually
The best way to map an XML model to a PDM is to use the XML Builder Wizard.
If you do not have a PDM, you can reverse engineer a database into a PDM.
For more information on reverse engineering a database into a PDM, see chapter Reverse engineering in a PDM, in the PDM User's Guide
.
WARNING! Caution
The following procedure assumes you have a PDM open in the workspace and targeted with Microsoft SQL Server 2000 as DBMS.
If the PDM is not targeted with the proper DBMS, select Database→Change Current DBMS.
To generate an annotated schema by mapping through the XML Builder Wizard:
- In the PDM menu bar, select Tools→XML Builder Wizard.
The Model Selection dialog box is displayed.
- Select the new model option. Type a name and a code for the new model, and select XML Schema Definition 1.0 or XML-Data Reduced 1.0 in the XML language list.
or
Select the existing model option. Select a model in the XML Model list. This model must be targeted with XSD or XDR.
- Click Next.
The Tables and Views Selection dialog box is displayed with the PDM tables list.
All tables are selected by default.
- <optional> Click the Deselect All tool and select the tables you want to generate into XML elements.
- Click Next.
The XML Hierarchy Design dialog box is displayed. By default, the XML hierarchy corresponding to the PDM is displayed in the right pane.
You can use the Properties tool to display the property sheet of the table selected in the left pane. The second tool allows you to add the selected object to the selected position in the XML model hierarchy. The last tool allows you to add to the XML model an object with the objects it is related to.
- Click the Element radio button, if you want to create columns as elements.
or
Click the Attribute radio button, if you want to create columns as attributes.
- Drag and drop tables from left to right panel to modify the XML hierarchy.
For more information on building an XML hierarchy, see section Generating an XML model via the XML Builder Wizard, in chapter Generating from a PDM, in the PDM User's Guide
.
- Click Finish.
The new XML model is displayed in the workspace with the generated elements and attributes.
In the case of an existing XML model, the generated elements appear next to the existing elements.
Extended model definitions
The
SQL/XML extended model definition is automatically attached to the generated XML model.
You can attach the
XML Document extended model definition to generate a simplified XML file that will help you understand the annotated schema. (See Note in step 11)
- In the XML model menu bar, select Model→Extended Model Definitions.
The List of Extended Model Definitions is displayed.
- Click the Import an Extended Model Definition tool.
The Extended Model Definition Selection dialog box is displayed.
- In the XML in Database tab, select Microsoft SQL Server.
Note: In the General Purpose tab, you can select the XML Document extended model definition to generate a simplified XML file that will help you understand the annotated schema.
- Click OK.
Microsoft SQL Server is displayed in the List of Extended Model Definitions.
- Click OK.
The Microsoft SQL Server extended model definition is displayed in the Browser tree view, attached to the generated XML model.
Annotated schema preview
By clicking the Preview tab of the model property sheet, you can have a preview of the annotated schema.
- Select Language→Generate XML Schema Definition File.
or
Select Language→Generate XML-Data Reduced File.
The Generation dialog box is displayed with Microsoft SQL Server selected in the Targets tab.
- Click the Select a Path button, beside the Directory box, to select a path for the annotated schema file.
- Click OK.
The Result dialog box is displayed with the path of the annotated schema file selected.
- Click Edit.
The annotated schema is displayed in the editor window.
Note the SQL namespace (with the sql prefix) and the SQL annotations for tables (sql:relation), columns (sql:field) and reference (sql:relationship).
- Click Close in the Result dialog box.
Copyright (C) 2007. Sybase Inc. All rights reserved.
|
|