Need to read two xml files using parallel job

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
deepa.y
Participant
Posts: 56
Joined: Mon Nov 28, 2011 10:47 pm
Location: Bangalore

Need to read two xml files using parallel job

Post by deepa.y »

Hi,
I created a parallel job to parse the xml.The job has the following stages.

External_source stage--->XML_input stage--->Sequential file stage.

I can parse the xml successfully using the above job.
But ,from source i am getting xml files with different elements in it.
Is that possible to parse that xmls with different elements and different namespace declarations using same job design?
felixyong
Participant
Posts: 35
Joined: Tue Jul 22, 2003 7:24 pm
Location: Australia

Re: Need to read two xml files using parallel job

Post by felixyong »

You can use the multi-instance in the Job Properties if that's what you're looking for.
Regards
Felix
deepa.y
Participant
Posts: 56
Joined: Mon Nov 28, 2011 10:47 pm
Location: Bangalore

Re: Need to read two xml files using parallel job

Post by deepa.y »

I will be getting many files from source and could not say the exact elements of those files.
even though the xml files contain the same elements,their namespace prefixes are different.
I am pasting 2 sample xml files.

XML1:
<Request>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelop ... sageHeader xmlns:ns37="http://csi.cingular.com/CSI/Namespaces/
Types/Public/SoapFaultDetails.xsd" xmlns:ns36="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireAccountProfileRequest.xsd" xmlns:ns35="http://csi.cingular.com/CSI/Namespaces/
Container/Public/EchoRequest.xsd" xmlns:ns34="http://csi.cingular.com/CSI/Namespaces/
Container/Public/AddNoteRequest.xsd" xmlns:ns33="http://csi.cingular.com/CSI/Namespaces/
Container/Public/UpdateSubscriberStatusResponse.xsd" xmlns:ns32="http://csi.cingular.com/CSI/Namespaces/
Container/Public/ActivateSubscriberResponse.xsd" xmlns:ns31="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireDeviceDetailsResponse.xsd" xmlns:ns30="http://csi.cingular.com/CSI/Namespaces/
Container/Public/UpdateSubscriberStatusRequest.xsd" xmlns:ns29="http://csi.cingular.com/CSI/Namespaces/
Container/Public/AddNoteResponse.xsd" xmlns:ns28="http://csi.cingular.com/CSI/Namespaces/
Container/Public/AddAccountResponse.xsd" xmlns:ns27="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireCreditCheckResultRequest.xsd" xmlns:ns26="http://csi.cingular.com/CSI/Namespaces/
Container/Public/EchoResponse.xsd" xmlns:ns25="http://csi.cingular.com/CSI/Namespaces/
Container/Public/UpdateAccountProfileResponse.xsd" xmlns:ns24="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireFanProfileRequest.xsd" xmlns:ns23="http://csi.cingular.com/CSI/Namespaces/
Container/Public/UpdateAccountProfileRequest.xsd" xmlns:ns22="http://csi.cingular.com/CSI/Namespaces/
Container/Public/ReserveSubscriberNumberResponse.xsd" xmlns:ns21="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireSubscriberProfileRequest.xsd" xmlns:ns20="http://csi.cingular.com/CSI/Namespaces/
Container/Public/SwapEquipmentRequest.xsd" xmlns:ns19="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireDeviceDetailsRequest.xsd" xmlns:ns18="http://csi.cingular.com/CSI/Namespaces/
Container/Public/ActivateSubscriberRequest.xsd" xmlns:ns17="http://csi.cingular.com/CSI/Namespaces/
Container/Public/AddAccountRequest.xsd" xmlns:ns16="http://csi.cingular.com/CSI/Namespaces/
Container/Public/SendEmailRequest.xsd" xmlns:ns15="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireAccountProfileResponse.xsd" xmlns:ns14="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireCreditCheckResultResponse.xsd" xmlns:ns13="http://csi.cingular.com/CSI/Namespaces/
Container/Public/SendEmailResponse.xsd" xmlns:ns12="http://csi.cingular.com/CSI/Namespaces/
Container/Public/ReserveSubscriberNumberRequest.xsd" xmlns:ns11="http://csi.cingular.com/CSI/Namespaces/
Types/Public/ErrorResponse.xsd" xmlns:ns10="http://csi.cingular.com/CSI/Namespaces/
Container/Public/SendSmsResponse.xsd" xmlns:ns9="http://csi.cingular.com/CSI/Namespaces/
Container/Public/SwapEquipmentResponse.xsd" xmlns:ns8="http://csi.cingular.com/CSI/Namespaces/
Container/Public/InquireFanProfileResponse.xsd" xmlns:ns7="http://csi.cingular.com/CSI/Namespaces/
Container/Public/SendSmsRequest.xsd" xmlns:ns6="http://csi.cingular.com/CSI/Namespaces/
Container/Public/UpdateSubscriberProfileResponse.xsd"
[snip]
</Request>


XML2:

<Request>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<mes:MessageHeader xmlns:mes="http://csi.cingular.com/CSI/Namespaces/ ... Header.xsd">
<mes:TrackingMessageHeader>
<cin:version xmlns:cin="http://csi.cingular.com/CSI/Namespaces/ ... in:version>
<cin:messageId xmlns:cin="http://csi.cingular.com/CSI/Namespaces/ ... :messageId>
<cin:timeToLive xmlns:cin="http://csi.cingular.com/CSI/Namespaces/ ... timeToLive>
<cin:dateTimeStamp xmlns:cin="http://csi.cingular.com/CSI/Namespaces/ ... eTimeStamp>
</mes:TrackingMessageHeader>
</mes:MessageHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<inq:InquireUnifiedCustomerLoginProfileRequest xmlns:inq="http://csi.cingular.com/CSI/Namespaces/ ... equest.xsd">
[snip]
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</Request>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I haven't tried it, but "in theory" I suspect it will work, using the xmlInput Stage....of course, the details of namespaces and elements/attributes will have to be fully populated on each of the output links, and you won't be able to send the details down the "same" link, even if the documents are structured the same (the prefixes are "in" the xpath).

...unless you send the xml content thru a transformer and do some things like dynamically change the prefixes from one string to another BEFORE the xmlInput Stage...

How large are the files and how much data do you have? You might want to consider a Server Job here for simplicity, as the Folder Stage can easily lift the whole file and put it into a single column where you can transform the strings as needed.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
deepa.y
Participant
Posts: 56
Joined: Mon Nov 28, 2011 10:47 pm
Location: Bangalore

Post by deepa.y »

eostic wrote:I haven't tried it, but "in theory" I suspect it will work, using the xmlInput Stage....of course, the details of namespaces and elements/attributes will have to be fully populated on each of the outp ...
In the first XML,the column version has the xpath as /Request/soap:Envelope/soap:Header/ns5:MessageHeader/ns5:TrackingMessageHeader/ns1:version/text()

In the second XML,the column Version has the folliwing Xpath:
/Request/SOAP-ENV:Envelope/SOAP-ENV:Header/mes:MessageHeader/mes:TrackingMessageHeader/cin:version/text()

Similarly the namespace prefixes varies among different source files for each element and the xpath of elements varies.
So,when i try to read different xml files using the job,job is getting finished but no records are loaded as xpath differs.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!:

I edited your post to remove most of the examples as they really weren't needed and they were screwing with the formatting of this page making it hard to work with.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

While I believe you could do this by jumping thru some hoops and sending each file to its own XML Input stage, I don't see the point. Create two jobs.
-craig

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