Page 1 of 2

generating flat file from xml file

Posted: Fri Feb 29, 2008 10:30 am
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.

Posted: Fri Feb 29, 2008 10:36 am
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.

Posted: Fri Feb 29, 2008 12:12 pm
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?

Posted: Fri Feb 29, 2008 12:27 pm
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?

Posted: Fri Feb 29, 2008 12:41 pm
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.

Posted: Sat Mar 01, 2008 5:56 pm
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

Posted: Sun Mar 02, 2008 12:26 am
by lstsaur
Develop a server job, Seq_01--->Xml_Input_02--->Seq_03, to learn how to use XML stage. It's much easier.

Posted: Mon Mar 03, 2008 10:29 am
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?

Posted: Mon Mar 03, 2008 10:38 am
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.

Posted: Mon Mar 03, 2008 10:52 am
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?

Posted: Mon Mar 03, 2008 10:54 am
by chulett
Reread my post. Pay more attention to the initial stage, which is not a sequential file stage.

Posted: Mon Mar 03, 2008 1:23 pm
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".

Posted: Mon Mar 03, 2008 3:38 pm
by ray.wurlod
IS there a Folder stage in parallel jobs? If not, follow the suggestion of using an External Source stage.

Posted: Mon Mar 03, 2008 3:44 pm
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:

Posted: Mon Mar 03, 2008 4:22 pm
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.