How to convert table data into xml file using xml output
stage? please explain step by step;
Answers were Sorted based on User's Feedback
Answer / srinivas
Hi Mukti,
To load the data into XML file first you need import the xml metadata as you expected structure by using the .xsd file or .xml file.
While importing the structure you must careful about the structure and if any value is repeating then define as a key column.
For example in above xml structre child value is diffrent and parents are same for the three rows like below :
CHANGE NAME DATASOURCE ACTION VALUE
ADD MY GSDBDatabase READ 2011
ADD MY GSDBDatabase READ 2012
ADD MY GSDBDatabase READ 2013
in above table VALUE column is unique and other values are same Note: this is taken from XML definition on question i took only 5 columns because of space issue.
In this situation you should define VALUE column as key column in XML output stage.
Job structure should like below:
SourceStage ---->transformer ----> XML output Stage.
Note:Before loading data into XML file you must sort the data other wise order will be change, what ever order you have in source the same order will load in to XML file So these words are mindful.
If you face any problem please let me knoow.
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / muktimca
MY output file
<?xml version="1.0" encoding="UTF-8"?>
<defns:Provisioning
xmlns:defns="urn:ford/Application/ImportAuthorization/v1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<defns:Entity>
<defns:EntityName>
PUB
</defns:EntityName>
<defns:EntityType>
BF
</defns:EntityType>
<defns:User>
<defns:UserName>
D-KUCINA
</defns:UserName>
<defns:Role>
<defns:RoleName>
COVISINT
</defns:RoleName>
<defns:AttributeFunction>
<defns:AttributeType>
COMPOSITE
</defns:AttributeType>
<defns:Attribute>
<defns:ChangeType>
ADD
</defns:ChangeType>
<defns:Name>
SITE
</defns:Name>
<defns:DataSource>
IAR
</defns:DataSource>
<defns:Action>
READ
</defns:Action>
<defns:Value>
U6XTA
</defns:Value>
</defns:Attribute>
</defns:AttributeFunction>
</defns:Role>
</defns:User>
</defns:Entity>
<defns:Entity>
<defns:EntityName>
PUB
</defns:EntityName>
<defns:EntityType>
BF
</defns:EntityType>
<defns:User>
<defns:UserName>
KDUTTON
</defns:UserName>
<defns:Role>
<defns:RoleName>
COVISINT
</defns:RoleName>
<defns:AttributeFunction>
<defns:AttributeType>
COMPOSITE
</defns:AttributeType>
<defns:Attribute>
<defns:ChangeType>
ADD
</defns:ChangeType>
<defns:Name>
TOKEN
</defns:Name>
<defns:DataSource>
IAR
</defns:DataSource>
<defns:Action>
READ
</defns:Action>
<defns:Value>
WQRFQ
</defns:Value>
</defns:Attribute>
</defns:AttributeFunction>
</defns:Role>
</defns:User>
</defns:Entity>
<defns:Entity>
<defns:EntityName>
PUB
</defns:EntityName>
<defns:EntityType>
BF
</defns:EntityType>
<defns:User>
<defns:UserName>
L-LOZEN
</defns:UserName>
<defns:Role>
<defns:RoleName>
COVISINT
</defns:RoleName>
<defns:AttributeFunction>
<defns:AttributeType>
COMPOSITE
</defns:AttributeType>
<defns:Attribute>
<defns:ChangeType>
ADD
</defns:ChangeType>
<defns:Name>
SITE
</defns:Name>
<defns:DataSource>
IAR
</defns:DataSource>
<defns:Action>
READ
</defns:Action>
<defns:Value>
P879Y
</defns:Value>
</defns:Attribute>
</defns:AttributeFunction>
</defns:Role>
</defns:User>
</defns:Entity>
</defns:Provisioning>
<?xml version="1.0" encoding="UTF-8" ?>
- <ie:Provisioning
xmlns:ie="urn:ford/Application/ImportAuthorization/v1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:ford/Application/ImportAuthorization
/v1.0 ImportAuthorizationR3.xsd">
- <ie:Entity>
<ie:EntityName>PUB</ie:EntityName>
<ie:EntityType>BF</ie:EntityType>
- <ie:User>
<ie:UserName>vbeeram1</ie:UserName>
- <ie:Role>
<ie:RoleName>sta-engineer</ie:RoleName>
- <ie:AttributeFunction>
<ie:AttributeType>BASE</ie:AttributeType>
- <ie:Attribute>
<ie:ChangeType>ADD</ie:ChangeType>
<ie:Name>MY</ie:Name>
<ie:DataSource>GSDBDatabase</ie:DataSource>
<ie:Action>READ</ie:Action>
<ie:Value>2011</ie:Value>
<ie:Value>2012</ie:Value>
<ie:Value>2013</ie:Value>
</ie:Attribute>
- <ie:Attribute>
<ie:ChangeType>DELETE</ie:ChangeType>
<ie:Name>VL</ie:Name>
<ie:DataSource>GSDBDatabase</ie:DataSource>
<ie:Action>READ</ie:Action>
<ie:Value>2011</ie:Value>
<ie:Value>2012</ie:Value>
<ie:Value>2013</ie:Value>
</ie:Attribute>
</ie:AttributeFunction>
- <ie:AttributeFunction>
<ie:AttributeType>FILTER</ie:AttributeType>
- <ie:Attribute>
<ie:ChangeType>ADD</ie:ChangeType>
<ie:Name>BuyerFilter</ie:Name>
<ie:DataSource>simngDS</ie:DataSource>
<ie:Action>READ</ie:Action>
<ie:Value>P01</ie:Value>
<ie:Value>P02</ie:Value>
</ie:Attribute>
</ie:AttributeFunction>
</ie:Role>
</ie:User>
- <ie:User>
<ie:UserName>sstiles4</ie:UserName>
- <ie:Role>
<ie:RoleName>sta-engineer</ie:RoleName>
- <ie:AttributeFunction>
<ie:AttributeType>BASE</ie:AttributeType>
- <ie:Attribute>
<ie:ChangeType>DELETE</ie:ChangeType>
<ie:Name>VL</ie:Name>
<ie:DataSource>GSDBDatabase</ie:DataSource>
<ie:Action>WRITE</ie:Action>
<ie:Value>2011</ie:Value>
<ie:Value>2013</ie:Value>
</ie:Attribute>
</ie:AttributeFunction>
- <ie:AttributeFunction>
<ie:AttributeType>COMPOSITE</ie:AttributeType>
- <ie:Attribute>
<ie:ChangeType>ADD</ie:ChangeType>
<ie:Name>Team</ie:Name>
<ie:DataSource>simngDS</ie:DataSource>
<ie:Action>READ</ie:Action>
<ie:Value>Team1</ie:Value>
<ie:Value>Team2</ie:Value>
</ie:Attribute>
</ie:AttributeFunction>
</ie:Role>
</ie:User>
</ie:Entity>
</ie:Provisioning>
please find .xsd file below
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:ford/Application/ImportAuthorization/v1
.0"
xmlns:ie="urn:ford/Application/ImportAuthorization/v1.0"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="Provisioning"
type="ie:ProvisioningType" />
<xs:complexType name="ProvisioningType">
<xs:annotation>
<xs:documentation>
Root node where “Provisioning” is the name
of the app team.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Entity"
type="ie:EntityObjectType"
minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="EntityObjectType">
<xs:annotation>
<xs:documentation>
Type of entity either application or
business function.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="EntityName" type="xs:string"
minOccurs="1"
maxOccurs="1" />
<xs:element name="EntityType"
type="ie:EntityTypeType" minOccurs="1"
maxOccurs="1" />
<xs:element name="User" type="ie:UserType"
minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="UserType">
<xs:annotation>
<xs:documentation>
User Node, contains 1..n roles for a
user .
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="UserName" type="xs:string"
minOccurs="1" maxOccurs="1" />
<xs:element name="Role" type="ie:RoleType"
minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RoleType">
<xs:annotation>
<xs:documentation>
Role Node, contains all info for a
role
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="RoleName" type="xs:string"
minOccurs="1"
maxOccurs="1" />
<xs:element name="AttributeFunction"
type="ie:AttributeObjectType" minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="AttributeObjectType">
<xs:annotation>
<xs:documentation>
AttributeObject, contains all info for a
role
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="AttributeType"
type="ie:AttributeObjectTypeType" minOccurs="1"
maxOccurs="1" />
<xs:element name="Attribute"
type="ie:AttributeTypeType" minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="AttributeTypeType">
<xs:annotation>
<xs:documentation>
Attribute Node, contains all info for an
attribute.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="ChangeType"
type="ie:ChangeTypeType" minOccurs="1"
maxOccurs="1" />
<xs:element name="Name" type="xs:string"
minOccurs="1" maxOccurs="1"/>
<xs:element name="DataSource" type="xs:string"
minOccurs="1" maxOccurs="1"/>
<xs:element name="Action" type="ie:ActionType"
minOccurs="1" maxOccurs="1"/>
<xs:element name="Value" type="xs:string"
minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="AttributeObjectTypeType">
<xs:restriction base="xs:string">
<xs:enumeration value="BASE" />
<xs:enumeration value="FILTER" />
<xs:enumeration value="COMPOSITE" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="EntityTypeType">
<xs:restriction base="xs:string">
<xs:enumeration value="BF" />
<xs:enumeration value="APP" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ActionType">
<xs:restriction base="xs:string">
<xs:enumeration value="READ" />
<xs:enumeration value="WRITE" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ChangeTypeType">
<xs:restriction base="xs:string">
<xs:enumeration value="ADD" />
<xs:enumeration value="DELETE" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
| Is This Answer Correct ? | 1 Yes | 0 No |
Name the different types of Lookups in Datastage?
Is it possible to query a hash file?
What is the command line function to import and export the ds jobs?
Wat is isolation level and when do u use them?
In my previous project we get data from mainframe and load it into datastage DB2 tables.Sometimes we get data as flat file or a mainframe tables itself directly we fetch the data.Is this a migration project?
what is the difference between == and eq in UNIX shell scripting?
what is the definitions for Datawarehose and Datamart?
SOURCE LIKE I_D,F1,F2 --------- 100,N,Y 100,N,N 100,Y,N 101,Y,Y 101,N,Y 102,Y,N 103,N,N 104,Y,Y 105,N,N 106,N,Y 102,N,Y 105,Y,Y O/P LIKE ID flag1 flag2 101 Y Y 101 N Y 102 Y N 102 N Y 104 Y Y 106 N Y
What is the use of hoursfromtime() function in transformer stage in datastage?
How can we perform 2nd time extraction of client database without accepting the data which is already loaded in first time extraction?
How to implement complex jobs in data stage?
Hi Friends, I have a input data like, class_id Marks 101 50 101 60 101 40 102 90 102 35 And i want my output data like class_id Marks Rank 101 50 2 101 60 1 101 40 3 102 90 1 102 35 2 how to do this in datastage?
8 Answers Cognizant, HCL, TIAA CREF,