XML file processing with missing elements

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Siddharth3012
Participant
Posts: 10
Joined: Sat Dec 22, 2007 12:09 am
Location: Gurgaon

XML file processing with missing elements

Post by Siddharth3012 »

Hi friends,

I have to generate an error file while reading the XML file source. XML source contains the information regarding customers in customer data set and each customer data set contains various data elements (tags).There are some required data elements (tags) that should be present in the XML file. The error file should contain the information regarding the missing required data elements for particular customer data set. I can successfully read the XML file but would'nt be able to find out How should i process the XML file to detect the missing required data elements in XML file.

For example :
we have XML file like this:
<AcisXML>
<Customers>
<Customer Customer_ID="356843">
<Data>
<Entry EffDt="2007-01-01" TermDt="9999-12-31" TID="136030">
<CES_Customer_Number>0710984</CES_Customer_Number>
<Original_Effective_Date>2007-01-01</Original_Effective_Date>
<Market_Segment_Code>MM1</Market_Segment_Code>
<CES_Market_Segment_Code>050</CES_Market_Segment_Code>
<Market_Segment_Name>Key Accounts (51-500 Lives)</Market_Segment_Name>
<Organization_Type>Corporation</Organization_Type>
<Spin_Off_Indicator>N</Spin_Off_Indicator>
<Eligibility_Service_Center>775</Eligibility_Service_Center>
<Eligibility_Service_Center_Name>Tampa</Eligibility_Service_Center_Name>

</AcisXML>.

Let us assume "CES_Customer_Number" data element is required field. So we need to prepare an error log file which contains the list of customers which do not have this data element in their data set in XML file.

Can you please help How can i process this logic?

Thanks in advance!
Siddharth Pratap Singh
Datastage Developer
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

The "simple" answer is that elements that are truly missing from the document (you have a column and proper xpath, but for a particular node, the element just isn't there) will simply come into the link as "null". You can then test them for nulls on that row inside a transformer.

It can possibly get more complicated than that, but the default covers most scenarios.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Roopanwita
Participant
Posts: 125
Joined: Mon Sep 11, 2006 4:22 am
Location: India

Post by Roopanwita »

Can anyone please explain me what is meant by Data element...
Thanks in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In XML a data element is (simplistically) a container for zero or more data attributes.

In DataStage, a Data Element is a great way to attach more information to a column about its purpose and other business metadata. One can perform Usage Analysis on a Data Element, for example to answer the question "which jobs deal with telephone numbers?".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Roopanwita
Participant
Posts: 125
Joined: Mon Sep 11, 2006 4:22 am
Location: India

Post by Roopanwita »

Thanks for reply.But I could not see your complete answer.
Thanks once again.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You really should just Google for stuff like this. For example:

http://www.ibm.com/developerworks/xml/l ... leatt.html
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply