Reading XML

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Reading XML

Post by Smeitei »

Hi i have come across two features in DataStage

1. XML Input
2. XML Reader

My requirement is to read XML from a folder(which contains lot of xml) and populate it to a sequential file . Which one of the above feature suit my requirement?

I have used XML input before to fetch XML from a MQ and populate a sequential file. If in the above problem if i have to use XML READER then please throw some light on how to use it
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Never heard of nor seen an XML Reader stage, where did you 'come across' it?

XML Input
XML Output
XML Transformer


Are the three XML related stages in the product. For your requirement, a typical job design would look something like:

Folder -> XML Input -> Transformer -> Sequential File

Suggest you also read the XMLPACK_20_Designer.pdf document that ships with the client and is installed on your pc in the 'Docs' folder.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Post by Smeitei »

I have tried out this option taking hints from discussion postedbefore

1st stage - Used Folder Stage.

In the OUPUT tab of the FOLDER stage, i have defined this 2 columns
FILENAME (DEFINEd as a key with SQLtype VARCHAR)
RECORD(Defined as SQLtype LONGVARCHAR with length like 99999999)

2nd stage - used XML Input stage.

In Input tab, defined XML Source RECORD(which was defined in the FOLDER stage).Then in the COLUMNS tab , again I have defined the columns as FILENAME and RECORD

In output tab under description i use this to get the column

/defns:qaar_na_pi/defns:claim_office_info/defns:co_office_name/text()

3rd Stage - Transformer map the column

4th Stage - Sequential file


I get this error

readfromfolder4..XMLInput_21: Unable to resolve prefix 'defns'.
|pattern = '/defns:qaar_na_pi/defns:claim_office_info/defns:co_office_name'(Unknown URI, 12, 118)|
Remaining tokens: ('/')
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

You can find similar postagain answered by Craig.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Post by Smeitei »

My XML look like this

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<qaar_na_pi xmlns:ns1="http://www.drivelogic.com/services/qaar ... ataobj/xml">
<report_info>
<rpt_date>01/19/2007</rpt_date>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I presume there's more than that - at least a closing tag for report_info?

Have you attempted to create a job that uses the XML Input stage to extract data from the XML? If so, can you describe this job - what stages are in it and how you configured the XML Input stage?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Post by Smeitei »

Yes indeed its a big XML but i have given just the starting information of the XML ...

I have used folder,XMl input,transformer and seq file stages..

Please refer the chain to get the way i have proceeded
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Post by Smeitei »

Can someone throw some light into this
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You can. What have you tried since your first post? Narasimha posted a link to another thread but you never said if it helped, what you tried, errors you are getting... other than the little bit in your first post.

How have you defined your namespaces in the XML stage? Specifically, the 'default namespace' or defns that it is complaining about.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Post by Smeitei »

The job runs without any error and i see the rows being picked up but it is not being written to the file

i am getting this error now.

CopyOfContracttrial..XMLInput_1: Xalan warning (publicId: , systemId: , line: 0, column: 0): An exception occured! Type:RuntimeException, Message:Warning: The primary document entity could not be opened. Id=contract.xsd


I have imported the metadata of the table from XML file
Smeitei
Participant
Posts: 28
Joined: Tue Jan 23, 2007 3:14 pm

Post by Smeitei »

In DS version 6 always use transformer before and after XML parser .

Once i put a transformer between folder stage and Xml parser the job executed as if there never was no error.

thanks all for ur reply
Last edited by Smeitei on Fri Mar 02, 2007 11:15 am, edited 1 time in total.
Kumudhini
Participant
Posts: 3
Joined: Tue Feb 27, 2007 10:39 pm

Post by Kumudhini »

Hai,
i tried the following design using ascential datastage
folder->xmlInput->seq file-> xmlOutput
the input and output are as follows

<?xml version="1.0" encoding="UTF-8"?>
<customers>
<customer id="5000">
<name>mike</name>
<address>
<city>redwood</city>
</address>
<address>
<city>foster</city>
</address>
<name>nandy</name>
</customer>
</customers>


<?xml version="1.0" encoding="UTF-8"?>
<customers>
<customer id="5000">
<name>mike</name>
<address>
<city>chennai</city>
<city>foster</city>
</address>
</customer>
</customers>

I am addressing the following problems
1)city "redwood" and "foster" comes under the same elements ie: address
2)the name "nandy" is missing.

1)I tried using different primary keys when loading the metadata.
2)I tried using a transformer stage before and after the xmlInput like how it was suggested in the discussing forum.
But the problem of missing some values as well having values at wrong positions were not solved. Iam neither getting any warning not fatal errors.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Kumudhini - welcome. Before anyone can really help you, you need to correct a couple of problems.

1) You need to start a new post in the appropriate Forum. Jumping on to the end of someone else's resolved problem is frowned upon. Biggest reason is we have no idea what your 'particulars' are - job type, version, Operating System, nothing.

So please, post this again in either the PX or Server forum depending on which job type you are working with.

2) Need more information. When you do start your new thread, let us know about your metadata. Did you import it from an xsd or did you create the xpath expressions by hand? Which field are you marking as a Key (you can only have one)? What is your goal here? Are you trying to read in some XML and then write it back out again in the same format? What options do you have enabled in the XML Output stage?

That kind of information - not here, but in your new post - will help get this resolved quicker. Thanks.
-craig

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