Вы находитесь на странице: 1из 13

Creating and Editing a PowerCenter XML Definition

2009 Informatica Corporation

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.

Importing an XML Definition


You can create an XML definition in PowerCenter from an XML file, DTD file, XML schema, flat file definition, or relational table definition. When you create an XML definition, the Designer extracts XML metadata and creates a schema in the repository. The schema provides the structure from which you edit and validate the XML definition in the Designer. Use the following rules and guidelines when you import an XML file: Use an XML schema or DTD file. When you import a source definition from an XML schema file or DTD file, the Designer creates an accurate definition of the data based on the description provided in the schema or DTD. When you create the XML definition from an XML document without an associated schema or DTD, you can get unexpected results. The Designer determines the types and occurrences of the XML elements based on data in the XML file. The Designer might define inaccurate attributes for columns. If you do not define default column lengths, the precision for some columns might be set to infinite.

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.

Choosing Import Options


A PowerCenter XML definition consists of one or more groups. A group is a set of ports that defines a row of incoming or outgoing data. Each PowerCenter group appears as an XML View in the XML Editor. When you import the XML definition, you can choose options that change the way the ports are organized into views. Choose one of the following options to create the XML views:
Import Option Description

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.

Custom XML views

Do not generate XML views

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.

Creating Custom Views


An XML document can have one root element. However, a DTD or schema can represent multiple instance documents. Each instance document might have a different root. You can create a PowerCenter XML definition from a root element that you choose and you can create an XML definition for a segment of the XML schema. For example, the following figure shows a PowerCenter XML definition that you create with hierarchy relationships:

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.

Metadata Explosion Options


The Metadata Explosion Options dialog box appears after you choose a root for custom XML views. The Metadata Explosion dialog box provides several options you can choose to change how elements are organized into views.

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.

Understanding the View Row Element


When you define a view in the XML Editor, you create the view row, an element or a global complex type that the Integration Service requires to generate a row of data. The Integration Service determines when to read and write data for an XML view by the value of the view row element. The Integration Service returns a row from a view when the value in the view row element changes. For example, the Product view contains elements Product, PID, PName, and Price. When you set the view row to Product, the Integration Service extracts data using the following algorithm:
For every Product extract ./PID/PName/Price

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.

Understanding XML View Relationships


The XML Editor workspace can show two types of XML views. A hierarchy view represents any portion of the schema hierarchy. A type view represents a type in the schema. The XML Editor can represent the following types of relationships between views: Hierarchy relationship. A parent-child relationship between two XML views. Two views can have one hierarchy relationship. For example, Sales is a child of Product:

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.

Editing XML Views


You can modify an XML definition. When you import an XML definition, the Designer creates a schema in the repository. You can add, change, and delete views in the XML Editor based on the schema. When you modify elements in an XML view, you change the columns in the PowerCenter XML definition. The schema in the repository does not change.

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.

To delete a column in a view:

Creating Views Manually


You can add or change views in an XML definition that you generated with Entity or Hierarchy relationships. To create all the XML views manually, select the Do Not Generate Views option when you import the XML definition. The Designer creates the XML schema definition in the repository, but does not create XML views. You can configure the XML views in the XML Editor. To open the XML Editor, double-click the top of the XML definition in the Designer workspace.

Creating an XML View


When you create an XML view, choose elements from the XML schema and drag them into an empty view in the workspace. For each multiple-occurring element create a separate view and establish a relationship between that view and a parent view. To create an XML view, use the following steps: 1. 2. In the Designer workspace, double-click the top of the XML definition to open the XML Editor. Click XMLViews > Create XML View. The XML Editor creates a blank view in the workspace. The Schema Navigator is the left panel of the XML Editor. It lists the elements in the XML schema in alphabetical order. The Schema Navigator lists an element more than once if it occurs as a child element. For example, the Product element appears twice in the Schema Navigator, once as a global element, and once under the Store element:

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.

Element Context in the XPath Navigator


The XPath Navigator provides a context to an element that you add to the XML view. For example, Product is a multiple-occurring element under Store. If you want to create a Product view, select the global Product element in the Schema Navigator and select XPath Navigator. If you choose the global Product element, you can add the Product element to a view as the view root:

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:

Creating Relationships between Views


When you create relationships between views, the XML Editor adds primary and foreign keys to the views. The keys define a relationship between two views. The relationship is a path from the parent view row to the child view row. The relationship must be valid according to the XML schema. The XML Editor does not allow you to create invalid relationships.

10

Hierarchy View Relationships


To create a hierarchy relationship between views, right-click the child view in the XML workspace. Select Create Relationship. Move the pointer to the parent view to create a link between the views. The XML Editor creates primary and foreign keys and a link appears between the views in the workspace.

Type View Relationships


To create a type relationship, right-click the column to define its type. Select Create Relationship. Move the pointer to the view that defines the type.

Inheritance View Relationships


To create an inheritance relationship, right-click the derived type and select Create Relationship. Move the pointer to the parent type view.

Expanding a Complex Type


An XML schema can define a complex type that is a base type for more than one derived types. For example, a Publication can be a Magazine or a Newspaper. When you create an XML view you can choose to include columns from the Magazine or a Newspaper type in the XPath Navigator. When you select an element that is defined as a base complex type in the XPath Navigator, you can add columns from the derived types. For example, the Publication element is a Publication type.

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.

Generating Views in the XML Editor


You can regenerate selected views in the XML Editor after you import the XML definition. You might need to regenerate a view if you made a mistake while editing a view. Or, you might want to manually create some views and generate the other views with the XML Editor. When you generate views, you can overwrite existing views or keep the views you already created in the XML definition. To generate views in the XML Editor: 1. Select a complex element in the Schema Navigator that represents a root element for the new views. For example, if you choose Product, the Designer generates a view for Product and the elements that fall below Product in the hierarchy. It might generate multiple views. 2. 3. 4. Click Components > Entity Relationships Wizard. The Recreate Entity Relationships dialog box appears. Choose the metadata explosion options for the views. Select what to do with existing views: Share Existing XML Views. Keep the existing views in the XML workspace. If you clear this option, the Designer ignores the existing views and creates duplicates. Refresh Shared XML Views. If the XML definition has existing views, update the views. If you clear this option, the Designer creates new views, but does not update views that already exist in the XML definition. 5. Click Next. The Entity Relationship dialog box lists elements in the schema that you might use as view roots. Each selected element is a root for a separate 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

Вам также может понравиться