Page 1 of 1

XML InputStage Write Issue

Posted: Tue Jan 18, 2011 1:22 pm
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....

Posted: Tue Jan 18, 2011 2:40 pm
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

Posted: Wed Jan 19, 2011 12:46 am
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.

Posted: Thu Jan 20, 2011 6:01 pm
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.

Posted: Fri Jan 21, 2011 3:21 am
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.

Posted: Fri Jan 21, 2011 5:47 am
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()

Posted: Fri Jan 21, 2011 5:55 am
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.

Posted: Fri Jan 21, 2011 6:02 am
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.

Posted: Fri Jan 21, 2011 7:42 am
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 ...

Posted: Fri Jan 21, 2011 11:29 am
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.

Posted: Fri Jan 21, 2011 11:35 am
by eostic
Excellent. Glad you got it working.

Posted: Fri Jan 21, 2011 11:44 am
by Ravi.K
Yes, Your help is appreciatable especially on XML stuff.

Thanks...