Page 1 of 1

Requirement in XML stage in Datastage 8.5

Posted: Wed Aug 03, 2011 12:15 pm
by ragavendradineshdsx
Hi all,

I have a unique requirement in the new XML stage in Datastage 8.5. Let me give you a sample XSD file below.

----------------------------------------------------------------------------------
<xs:element name="ContactInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="ContactType" type="xs:string"/>
<xs:element name="TypeValue" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="EmployeeID" type="xs:string"/>
<xs:element ref="ContactInfo"/>
</xs:sequence>
</xs:complexType>
</xs:element>

----------------------------------------------------------------------------------

In the XSD, "Employee" is my root element and under employee node, we have "ContactInfo" as one of the child node. This ContacInfo element can have 2 sub-nodes
"ContactType" and "TypeValue". Let me come to the issue. As per my requirement, there are 2 types of values possible for "ContactInfo". Either it can be "Telephone" related information
or it can be "Email" related informations. For eg --> an employee can have both the informations as well. In that case, I need to get 2 seperate tags in the XML.
I will give a fair idea of how my source would look like.


Input row:

EmployeeID||ContactTypeTelephone||TypeValueTelephone||ContactTypeEmail||TypeValueEmail
0001||Mobile||9XXXXX 9XXXXX||PersonalEmail||aaa@email.com
0001||Pager||12XXXX ||NULL||NULL


My Output should be:

<Employee>
<EmployeeID>0001</EmployeeID>
<ContactInfo>
<ContactType>Mobile</ContactType>
<TypeValue>9XXXXX 9XXXXX</TypeValue>
</ContactInfo>
<ContactInfo>
<ContactType>Pager</ContactType>
<TypeValue>12XXX</TypeValue>
</ContactInfo>
<ContactInfo>
<ContactType>PersonalEmail</ContactType>
<TypeValue>aaa@email.com</TypeValue>
</ContactInfo>
</Employee>


I'm able to achive the output only for Mobile and Pager but i'm not able to include EMAIL in my XML output.
I'm using "Re-Group" step and "XML Composer" steps in my XML stage. Please help me out to achive this output.

Posted: Thu Aug 04, 2011 7:22 am
by eostic
Try pivoting it first so that the number of rows in the incoming link "list" is the same as the number of nodes you want in your target "list". (ie..get email onto its own row)

Ernie