XML InputStage Write Issue

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
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

XML InputStage Write Issue

Post by Ravi.K »

Hi,

I have a xml file as source and Target is sequential file. The job flow is as follows.

External Source -- > XML Inputstage --> Sequential file

External source properties:

Source method: Specific Program
Source Program: find path -name "filename" -print
Record Type: implicit
Delimiter: None

Defined one column of maximum length.

XML Input Stage:

Stage Tab--> Transformation Setting --> Checked Repetition Element Required

Input Tab --> XML source --> XML Source column as the column defined at External Source and checked Column Content as "XML document"

Output Tab --> Columns --> defined 2 columns.

customername--varchar(30)
customertype -- varchar(10)

by providing the following "description".

customername-- /Customerlist/customer/customername/text()
customertype -- /Customerlist/customer/Customertype/text()

Job is finishing without any errors or warnings. But the data is not getting write to sequential file. Please find the sample XML feed.

<?xml version="1.0"?>
<Customerlist>
<customer>
<customername>ABC Limited</customername>
<Customertype>WB</Cutomertype>
</customer>
<customer>
<customername>Nelson</customername>
<customertype>CB</customertype>
</Customer>
</Customerlist>

Please help on it....
Cheers
Ravi K
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I've never tried using that technique in the External Source stage... I would suggest you use list (ls) and send the list of filenames, and then change the check box to "url" inside of the xmlInput Stage (see the table of contents at www.dsrealtime.com for an entry on xml and how to define sources).

Otherwise, it looks like you should be ok...everything else seems ok, assuming you have one of those two columns checked as a "key" (repetition element).

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

As you suggested, i have used "ls" command to list the file at External source and after tried view data then i got the URL as good as follows.

/home/bslops1/ravi/ABC.xml

Changed column content to "URL/File Path" and already defined 1 column as Key.

Providing the following "description" at XML InputStage--> Output-->Columns --> "Description"

customername--> /Customerlist/customer/customername/text()
customertype --> /Customerlist/customer/Customertype/text()

Job completed without any errors and warning.. But no records at Target.
Cheers
Ravi K
prakashdasika
Premium Member
Premium Member
Posts: 72
Joined: Mon Jul 06, 2009 9:34 pm
Location: Sydney

Post by prakashdasika »

you have to read the element 'customer' in the output and define it as the key along with the text fields from the element. It has worked for me. The input as you mentioned should be a 'FilePath' and read as single column.

Remember to give Xpath expressions correctly.
Prakash Dasika
ETL Consultant
Sydney
Australia
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

prakashdasika wrote:you have to read the element 'customer' in the output and define it as the key along with the text fields from the element. It has worked for me. The input as you mentioned should be a 'FilePath' and read as single column.

Remember to give Xpath expressions correctly.
As you suggested i read the element by defining it as key at output. The input as File Path and Single column.

Imported XML meta data. Defined the XPATH. For your referrence find the XPATH.

/customerlist/customer
/customerlist/customer/customername/text()
/customerlist/customer/customertype/text()

But still no errors or warnings. There is no data at Target.
Cheers
Ravi K
nayanpatra
Participant
Posts: 41
Joined: Sat Jun 06, 2009 11:13 pm
Location: Kolkata

Post by nayanpatra »

From the example that you gave, I think will have only 2 columns in the output

Customer name: /customerlist/customer/customername/text()
Customer type: /customerlist/customer/customertype/text()
Nayan
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Yes, I have 2 columns only when thread was initially started. But after as per suggestions by prakash, i added one more column.
Cheers
Ravi K
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

I enabled "Log Reject Errors". Now it catch up with an Warning. Please find the Warning details.

XML input document parsing failed. Reason: Xalan fatal error (publicId: , systemId: , line: 0, column: 0): An exception occurred! Type:RuntimeException, Message:The primary document entity could not be opened. Id=/home/bslops1/ravi/ABC.xml

But when i checked at the server the file is available.

/home/bslops1/ravi>ls -lrt ABC.xml
-rw-r--r-- 1 bslops1 dstage 238 Jan 19 13:47 ABC.xml
/home/bslops1/ravi>

Please help for the issue.
Cheers
Ravi K
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Make sure you can open the document yourself using IE. Something is failing in its structure, or odd characters, or else maybe the way you are reading it via the External Source stage is an issue. I always use ls ...
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

eostic wrote:Make sure you can open the document yourself using IE. Something is failing in its structure, or odd characters, or else maybe the way you are reading it via the External Source stage is an issue. I always use ls ...
Earine your anticipation is correct. I changed column length to 100 at external source and there are some problems at XML source also find out when i was opened in IE (Problem is at Tags <customer> and </Customer>. The letters are case sensitive and changed that letters and issue is resolved)

Tried using the following mechanism and works fine with External source.

Source method: Specific Program
Source Program: echo /home/bslops1/ravi/ABC.xml

Or

Source Program:ls /home/bslops1/ravi/ABC.xml

Thanks a lot for all your inputs.
Cheers
Ravi K
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Excellent. Glad you got it working.
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Yes, Your help is appreciatable especially on XML stuff.

Thanks...
Cheers
Ravi K
Post Reply