Reading XML
Moderators: chulett, rschirm, roy
Reading XML
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
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
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.
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
"You can never have too many knives" -- Logan Nine Fingers
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: ('/')
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: ('/')
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>
<?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>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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?
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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.
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
"You can never have too many knives" -- Logan Nine Fingers
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
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
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
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.
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.
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.
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.
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
"You can never have too many knives" -- Logan Nine Fingers