generating flat file from xml file

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

kirankota79
Premium Member
Premium Member
Posts: 315
Joined: Tue Oct 31, 2006 3:38 pm

generating flat file from xml file

Post by kirankota79 »

Hi,

I have an .xsd and .xml file. I have created a xml file definition with .xsd file.
Now i want to know what are the stage that i have to use to generate the data from xml file to a sequential file. i never used xml stages before. I appreciate if anybody can give some inputs.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The XML Input stage is used to read XML. You would feed that using an External Source stage, a search should turn up the specific techniques.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kirankota79
Premium Member
Premium Member
Posts: 315
Joined: Tue Oct 31, 2006 3:38 pm

Post by kirankota79 »

<?xml version="1.0" encoding="ISO-8859-1"?>

<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="shiporder.xsd">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>


This is the example xml file that i am using and i am using external source stage before xml input stage

It is compiling but when i run it i get the following errors:

XML_Input_0: Error when checking operator: Could not find input field "shiporder"
Error when checking operator: Could not find input field "orderid"
Error when checking operator: Could not find input field "orderperson"
Error when checking operator: Could not find input field "name"
Error when checking operator: Could not find input field "address"
Error when checking operator: Could not find input field "city"
Error when checking operator: Could not find input field "country"
Error when checking operator: Could not find input field "title"
Error when checking operator: Could not find input field "note"
Error when checking operator: Could not find input field "quantity"
Error when checking operator: Could not find input field "price"



can you please tell me the reason?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Does your External Source stage select just the filename and is your XML Output set to use Column Content: URL/File path via that one field?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kirankota79
Premium Member
Premium Member
Posts: 315
Joined: Tue Oct 31, 2006 3:38 pm

Post by kirankota79 »

i am using the source method as specific program and for source program, i am giving the path of the xml file. and under format tab iam using all delimiters and quotes as none. In the xml input stage, under the input and output tabs iam using url/path and selecting the column as shiporder , since it is at the start of the xml file.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

You want the source program to simply be "ls" (list)....and that sends the "name" of the XML documents into the XMLInput Stage. Search around for xml, or check out my blog link below -- I have the full syntax there for the "ls" for reading XML...

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

Develop a server job, Seq_01--->Xml_Input_02--->Seq_03, to learn how to use XML stage. It's much easier.
kirankota79
Premium Member
Premium Member
Posts: 315
Joined: Tue Oct 31, 2006 3:38 pm

Post by kirankota79 »

hi lstsaur..........i am trying now to create a server job in the manner you explained....i am getting the following error:

XmlTest_server..Sequential_File_0.DSLink3: nls_read_delimited() - row 1, column orderid, required column missing

Can u please tell me what could be the reason?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

lstsaur wrote:Develop a server job, Seq_01--->Xml_Input_02--->Seq_03, to learn how to use XML stage. It's much easier.
That should actually be:

Folder_01--->Xml_Input_02--->Seq_03

With perhaps a transformer in there as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kirankota79
Premium Member
Premium Member
Posts: 315
Joined: Tue Oct 31, 2006 3:38 pm

Post by kirankota79 »

even after i use the transfomer.....i am getting the error that i mentioned above for the i/p sequential file....please tell me what kind of settings i need to do in the i/p sequential file?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Reread my post. Pay more attention to the initial stage, which is not a sequential file stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

kirankto79,
I gave you an example to use the sequential file to pull in the xml instead of to use the Folder stage as Craig suggested.

For sequential file, just define the whole file as one large column, e.g. xmldoc, varchar 2048, then in your xml_input_02 Input tab's XML Source Column select the "xmldoc".
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

IS there a Folder stage in parallel jobs? If not, follow the suggestion of using an External Source 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kirankota79 wrote:hi lstsaur..........i am trying now to create a server job in the manner you explained....i am getting the following error:
-craig

"You can never have too many knives" -- Logan Nine Fingers
jmarutz
Participant
Posts: 5
Joined: Mon Jun 26, 2006 12:42 pm

Post by jmarutz »

It's pretty easy to handle XML in parallel. You don't use the sequential file unless you want to stream the data into the xml stage as a full xml document record. I wouldn't recommend that. You should be able to give it a path to the xml document. You can use the list approach in a previous post to do that.
Post Reply