In this lesson, you import an XML schema and create a custom view based on the schema. The custom XML target definition you create meets the following criteria:
Each department has a separate target and the structure for each target is the same.
Each target contains salary and department information for employees in the Sales or Engineering department.
Because the structure for the target data is the same for the Engineering and Sales groups, use two instances of the target definition in the mapping. In the following steps, you import the Sales_Salary schema file and create a custom view based on the schema.
In the Designer, switch to the Target Designer.
If the workspace contains targets from other lessons, right-click the workspace and choose
Clear All
.
Click
Targets
Import XML Definition
.
Navigate to the Tutorial directory in the PowerCenter installation directory, and select the Sales_Salary.xsd file. Click
Open
.
The
XML Wizard
appears.
Name the XML definition SALES_SALARY and click
Next
.
Select
Do not generate XML views
and click
Finish
.
The
XML Wizard
creates the SALES_SALARY target with no columns or groups.
Double-click the XML definition to open the
XML Editor
.
Click
XMLViews
Create XML View
.
The
XML Editor
creates an empty view.
Empty XML View
Right-click DEPARTMENT group in the
Schema Navigator
and select
Show XPath Navigator
.
From the
XPath Navigator
, drag DEPTNAME and DEPTID into the empty XML view.
The
XML Editor
names the view X_DEPARTMENT.
The
XML Editor
may transpose the order of the attributes DEPTNAME and DEPTID. If this occurs, add the columns in the order they appear in the Schema Navigator. Transposing the order of attributes does not affect data consistency.
In the X_DEPARTMENT view, right-click the DEPTID column, and choose
Set as Primary Key
.
Click
XMLViews
Create XML View
.
The
XML Editor
creates an empty view.
From the EMPLOYEE group in the
Schema Navigator
, Navigate to the
XPath Navigator
.
From the
XPath Navigator
, drag EMPID, FIRSTNAME, LASTNAME, and TOTALSALARY into the empty XML view.
The
XML Editor
names the view X_EMPLOYEE.
Right-click the X_EMPLOYEE view and choose
Create Relationship
.
Drag the pointer from the X_EMPLOYEE view to the X_DEPARTMENT view to create a link.
The
XML Editor
creates a DEPARTMENT foreign key in the X_EMPLOYEE view that corresponds to the DEPTID primary key.
Click
File
Apply Changes
.
The XML definition now contains the groups DEPARTMENT and EMPLOYEE.