Page 1 of 1

Reading XML

Posted: Tue Jan 30, 2007 2:33 pm
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

Posted: Tue Jan 30, 2007 2:51 pm
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.

Posted: Tue Jan 30, 2007 10:26 pm
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: ('/')

Posted: Tue Jan 30, 2007 10:33 pm
by narasimha
You can find similar postagain answered by Craig.

Posted: Wed Jan 31, 2007 1:02 pm
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>

Posted: Wed Jan 31, 2007 2:46 pm
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?

Posted: Wed Jan 31, 2007 4:09 pm
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

Posted: Thu Feb 01, 2007 9:47 am
by Smeitei
Can someone throw some light into this

Posted: Thu Feb 01, 2007 10:20 am
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.

Posted: Thu Feb 01, 2007 11:42 am
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

Posted: Tue Feb 13, 2007 4:28 pm
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

Posted: Wed Feb 28, 2007 3:35 am
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.

Posted: Wed Feb 28, 2007 7:46 am
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.