You are on page 1of 2

When you create an XML Parser transformation, use the XML Wizard to import an XML, DTD, or XML schema

file. For example, you can import the following Employee DTD file: - save below script in notepad and change .txt to .dtd

<!ELEMENT EMPLOYEES (EMPLOYEE+)> <!ELEMENT EMPLOYEE (LASTNAME, FIRSTNAME, ADDRESS, PHONE+, EMAIL*, EMPLOYMENT)> <!ATTLIST EMPLOYEE EMPID CDATA #REQUIRED DEPTID CDATA #REQUIRED> <!ELEMENT LASTNAME (#PCDATA)> <!ELEMENT FIRSTNAME (#PCDATA)> <!ELEMENT ADDRESS (STREETADDRESS, CITY, STATE, ZIP)> <!ELEMENT STREETADDRESS (#PCDATA)> <!ELEMENT CITY (#PCDATA)> <!ELEMENT STATE (#PCDATA)> <!ELEMENT ZIP (#PCDATA)> <!ELEMENT PHONE (#PCDATA)> <!ELEMENT EMAIL (#PCDATA)> <!ELEMENT EMPLOYMENT (DATEOFHIRE, SALARY+)> <!ATTLIST EMPLOYMENT EMPLSTAT (PF|PP|TF|TP|O) "PF"> <!ELEMENT DATEOFHIRE (#PCDATA)> <!ELEMENT SALARY (#PCDATA)>
The following figure shows the XML Parser transformation that the Designer creates if you choose to create entity relationships:

The Designer creates a root view, X_Employees. X_Employees is the parent of X_Employee. X_Employee is a parent of X_Salary, X_Phone, and X_Email. Each view in the XML Parser transformation has at least one key to establish its relationship with another view. If you do not designate the keys in the XML Editor, the Designer creates the primary and foreign keys for each view. The keys are of datatype bigint. The keys are called generated keys because the Integration Service creates the key values each time it returns a row from the XML Parser transformation. When the Designer creates a primary or foreign key column, it assigns a column name with a prefix. In an XML definition, the prefix is XPK_ for a generated primary key column and XFK_ for a generated foreign key column. A foreign key always refers to a primary key in another group. A generated foreign key column always refers to a generated primary key column. For example, the group X_Employee has the XPK_Employee primary key. The Designer creates foreign key columns that connect the X_Phone, X_Email, and X_Salary to the X_Employee group. Each group has the foreign key column XFK_Employee.

XML Parser Input Validation


You can configure the XML Parser transformation to validate XML before parsing it. The XML Parser transformation validates the XML against a schema. If the XML is not valid for the schema, a row error occurs. The XML Parser transformation returns the XML and associated error messages to a separate output group. You can pass the invalid XML and error message to a target.

You might also like