Академический Документы
Профессиональный Документы
Культура Документы
Abstract
When you import an XML definition to PowerCenter, the Designer creates the structure of the PowerCenter definition by default. This article explains how to define XML views manually in the Designer.
Table of Contents
Overview ........................................................................................................................................................................... 2 Importing an XML Definition.............................................................................................................................................. 2 Choosing Import Options .................................................................................................................................................. 3 Creating Custom Views .................................................................................................................................................... 4 Metadata Explosion Options......................................................................................................................................... 6 Understanding the View Row Element ............................................................................................................................. 6 Understanding XML View Relationships........................................................................................................................... 7 Editing XML Views ............................................................................................................................................................ 7 Creating Views Manually .................................................................................................................................................. 8 Creating an XML View.................................................................................................................................................. 8 Element Context in the XPath Navigator .................................................................................................................... 10 Creating Relationships between Views........................................................................................................................... 10 Expanding a Complex Type............................................................................................................................................ 11 Generating Views in the XML Editor ............................................................................................................................... 12
Overview
When you import an XML definition and choose entity relationships or hierarchy relationships, the Designer selects a default root and generates the XML definition. It creates the groups and columns in the XML definition. Sometimes you need to create an XML definition that includes only some of the elements in the schema. Or, you need to create a definition that matches the structure of target database tables. This article explains how to create XML views manually in the XML Editor. It also presents some additional recommendations for troubleshooting.
Validate the XML schema first. The Designer does not import an invalid XML schema or document. Before you import a schema, validate the XML file with a third-party tool, such as Altova XMLSpy. You can find errors in the schema before you import the file. Import files smaller than 100K. When you import an XML definition, it must be less than 100K in size. The Designer can create up to 400 views for an XML definition. If the import creates more than 400 views, the import stops. You can import the definition if you manually create views in the XML Editor. Set default column lengths. Configure a default length for elements with undefined lengths, such as strings. If you do not set a default length, and you create an XML definition from an XML document, the precision for some elements is infinite. Infinite precision can cause DTM buffer size errors when you run a session with large files. Configure the default length in the Change XML Views Creation and Naming Options dialog box. This dialog box appears when you import a file and click Advanced. You can also access the dialog box from the Tools menu in the XML Editor. Create views manually. When you import an XML definition you can have the Designer create XML views or you can create the views manually in the XML Editor. If you already have the target structure defined, create the XML views manually and configure the views to match the target tables. To create views manually, choose to skip generating views when you import the definition.
Hierarchy relationships
The Designer selects a root and creates relationships between parent and child elements in a hierarchy. Each reference to an element expands under its parent element. You can choose normalized XML views or denormalized XML views. - Normalized XML views. Elements and attributes appear once. Multiple-occurring elements or elements in one-to-many relationships appear in different views related by keys. - Denormalized XML views. Elements and attributes appear once. Multiple-occurring elements or elements in one-to-many relationships appear in different views related by keys.
Entity relationships
The Designer selects a root and creates separate views for complex types and multiple-occurring elements. It defines relationships and inheritance between complex types. It defines relationships between views with keys. The Designer creates an XML definition with a selected element as a root. Choose a global element to use as a root. The Designer creates a definition that includes the elements that occur beneath that root in the hierarchy. The PowerCenter XML definition might contain a segment of the elements in the schema depending on the element you choose. Select this option to manually define the XML definition in the XML Editor. The Designer imports the XML schema but creates no views or columns in the XML definition. Choose this option if you want to define the views and create the relationships between them.
When you create hierarchy relationships or entity relationships, the Designer creates the XML views by default. It creates the primary-key foreign-key relationships between views and defines the view rows. You can modify or delete the views that the Designer creates for hierarchy or entity relationships.
For information about creating hierarchical and entity relationships, see the PowerCenter XML Guide.
The Designer selected Store as the root by default. Each store has addresses, employees, and products. Each product has sales. If you want to create an XML definition just for Product, you can choose Custom XML Views and select Product as the root. If you import the same XML schema and choose to create custom XML views, the Designer displays the following dialog box:
The Root Selection dialog box displays a default top level root in the Selected Top Level Roots column. You can change the root. If you choose Product as a root, the Designer creates two views, Product and Sales:
Sales has a foreign key that relates each sale to a product. Since the root is Product, the XML definition does not contain views for Store, Address, or Employee. These elements are not beneath Product in the XML hierarchy. The following figure shows the Product and Sales views in the PowerCenter XML Editor workspace:
The view row for the Product view is Product. When the product value changes, the Integration Services returns a row that contains the PID, PName, and Price. Each product can have multiple sales. The Integration Service returns a row that contains Region and YtdSales each time Sales changes. You can choose more than one global element for a PowerCenter XML source definition. If you choose more than one root in the same hierarchy, the Designer creates a definition with one root. You can create an XML Source definition with views that are not related to each other. A PowerCenter target definition must have views that are related with primary keys and foreign keys.
Choose the following options: Reduce Element Explosion. Creates a separate view for an element if the schema references it more than once. Reduce Complextype Explosion. Creates a separate view for a complex type if the elements in the schema reference it more than once. Reduce Complex Type Inheritance Explosion. Creates a relationship between base complex types and derived or restricted types. Base type elements do not appear in the child elements. If you disable this option, the inherited elements from a parent type appear in the child types.
The view row element must be the lowest multiple-occurring element in an XML view hierarchy. The XML Editor does not allow you to add multiple-occurring elements below the view row element in a view. If you add a multiple-occurring element below the view row, the XML Editor changes the view row to the multiple-occurring element. However, you can add single instances of a multiple-occurring element below a view row. You can set a view row at a single or multiple-occurring element. Every element in a view has a one-to-one relationship to the view row when the Integration Service returns the row.
Type relationship. A type relationship must include one complex type and a column in another view. There can be more than one type relationship between the same XML views. A type relationship is always one-to-one. For example, Publication is a PublicationType:
Inheritance relationship. An inheritance relationship includes two complex types. One type is derived from the other. For example the following figure shows an inheritance relationship:
The BookType is derived from the PublicationType. In this example, metadata explosion is reduced. A book contains ISBN and Publisher, but the view does not include the Title and Date.
To delete an XML view: 1. 2. 1. 2. Right-click the top of the view in the XML Editor. Select Delete This XML View. Right-click the column in the view. Select Delete Column.
For this example, you might create a view for Store. You create separate views for Address, Product, and Employee because they are multiple-occurring child elements of Store. 3. To add a column to a view, right-click the column in the Schema Navigator and select XPath Navigator. The XPath Navigator dialog box appears.
4.
Click the XPath Navigator mode arrow at the top of the XPath Navigator. Choose an XPath Navigator mode. The XPath Navigator Mode defines how to add an element to a view. You can choose one of the following modes before you add an element to a view: Column mode. Add the element as a simple-type column in the view. If you add the first row of the view with column mode, the XML Editor displays a warning message and adds the column as a view row. You can another element to the view row at any time. Default mode is column. View row mode. Add the element as a view row column in the view. If another column is already the view row, the new element becomes the view row. Advanced mode. Add one instance of a multiple-occurring element. For example, Sales/Region is multipleoccurring element. Instead of creating a separate view for Sales, you can add one or more instances of Region to the Product view. Set the XPath Navigator to Advanced Mode and drag Region to the Product view. The XML Editor adds an instance of Region to the view each time you drag the Region to the Product view. For example, you might create three Region columns in the Product view. The Product element remains as the view row. The following figure shows an instance of Region in the Product view:
When you add more than one instance, the view in the XML workspace does not show each instance. The Columns view in the XML Editor displays each instance:
Note: The default XPath Navigator mode is column. You do not have to change the XPath Navigator mode unless you need to pivot a multiple-occurring element. To change a column to a view row, right-click the column in the view and choose Set As View Row. 5. Drag each element into the view. For the example XML definition, the Store view contains Store, SID, and Sname elements.
If you choose Product from within the Store element in the XPath Navigator, the XML Editor places the Product element under Store in the view:
10
Publication includes Title, Author, and Date. The XML schema includes a BookType and MagazineType. Books and magazines are publications that have additional information. When you configure the XML definition, you can create views for MagazineType and PublicationType. Or, you can create one XML view for a Publication and expand the view to include columns from MagazineType of PublicationType. To expand a complex type to include columns from the derived type: 1. Highlight the element that is the complex type in the XPath Navigator. For example, click the Publication element.
11
The Expand Complex Types list shows derived types you can choose for Publication.
2.
Select the type you want to use in a view. The columns from the derived type appear in the XPath Navigator. For example, if you choose BookType, the ISBN and Publisher columns appear in the XPath Navigator. You can add them to the Publication view.
12
In the following figure, Product and Sales are selected to be view roots:
6. 7. 8. 9.
Clear the Select Box for any view that that you do not want to generate. For example, clear the Select box for Sales if you do not want to generate a Sales view. To remove a column from a view, click the Element. The Designer displays a list of the child components for the view. Clear the selection box for each element to exclude from the view. Click Create to generate the views.
10. If you added new views to existing views, create relationships between the new views and the existing views in the workspace.
Author
Ellen Chandler Principal Technical Writer
13