Create xml files from flat files using schema 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

Post Reply
anusha
Premium Member
Premium Member
Posts: 37
Joined: Wed Nov 28, 2007 1:29 am
Location: pune

Create xml files from flat files using schema file

Post by anusha »

We have set of nearly 50 CSV files out of which we have create same set of 50 XML files in a single datastage job. For this we are trying to make use of Schema file functionlaity for reading the CSV files. so My design would be like:

Code: Select all

Sequential  --------> Copy Stage --------------->XML Output Stage
So will the XML out stage provide functionality of dynamically changing metadata definitions. Here am trying to avoid RCP enabled.

1. I had thought of using XSD files(50) for XML generation in XML transformer stage by parameterizing the XSD file names.Would this work, I can't test it now as I don't have DS environment setup.
Please suggest...
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

How dynamic do you need it to be? If you want to send the job an "externally" defined specification, then you will have to use xslt and supply that to the job at run time in the desired xml stage...

...then it's really more of an xsllt project, with the xslt conforming to DataStage and then doing whatever it is you need it to do...

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

"xsllt project"? Google is telling me that's a typo, so assuming you just meant "xslt project", yes?
-craig

"You can never have too many knives" -- Logan Nine Fingers
anusha
Premium Member
Premium Member
Posts: 37
Joined: Wed Nov 28, 2007 1:29 am
Location: pune

Post by anusha »

1. Will XSLT helps in converting relational/tabular data into XML data?, I thouhgt, it needs only XML data as input to do any processing...

2. If XSLT supports relational data to XML conversion, then,
I have 50 CSV files & am using 50 differernt corresponding schema files to read them in a single DS job. Can XML transformer stage supports runtime metadata functionality (as I have schema file for reading),so that for a file I will assign a specific Schema file & specific XSLT to generate an XML file. Will this functionality be possible.

Thanks,
Anusha
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

That was a typo up above. ; ) We're talking xslt here....

All I am implying with xslt (using either the XMLTransformer Stage or the new XML Stage in 8.5) is that xslt is the only way that you would be able to make the parsing and column work entirely dynamic..... and even then, it probably won't deliver exactly what you are looking for.

The XML Stages (unless you resort to the largely custom solution with XML Transformer and XSLT) in pre-8.5 use xpath that is "inside" the link. It is not dynamic --- you can't change it without a re-compilation of the Job. ...and in 8.5 a formal xml schema definition is required.

Take us higher up...what is your ultimate goal here? Having 50 different output (for different nodes, etc.) is entirely do-able within the Stage...but the links have to be defined and in your Job.....the Stage will take care of sending the output to the appropriate link depending on the incoming content.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
anusha
Premium Member
Premium Member
Posts: 37
Joined: Wed Nov 28, 2007 1:29 am
Location: pune

Post by anusha »

Take us higher up...what is your ultimate goal here? Having 50 different output (for different nodes, etc.) is entirely do-able within the Stage...but the links have to be defined and in your Job.....the Stage will take care of sending the output to the appropriate link depending on the incoming content.
Hope, we are not on the same page here. let me brief again.
Actually we have dynamically changing Input over that we have create respective XML files.

I have source files like CSV1,CSV2, CSV3...CSV50 and these should be converted to XML1,XML2,XML3.....XML50. All the Input is not part of a single node of single file but each details will part indepedent source files.
What we wanted here is 1:1 mapping should be built between CSV:XML.

And our query over this, Is this achievable in a single Datastage Job or we need 50 DS jobs specific to each files as each file has got it's own metadata defined in it.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

I'd consider other factors also before making a decision on which way to go here.....consider such things as:

Is the max number of files 50? Or is that just your current number, and it could eventually be 500?

Are the files large? or will they eventually be large? Will you need parallel processing of xml along the way?

Will you want/need formal validation against a schema as you build each xml?

Will you eventually be reading that xml with DataStage, and converting back into csv?

Fifty is a lot, but if that's the final number, developing 50 links or 50 separate Jobs won't be "too" bad, and then you will have all the benefits offered by the new or existing stage and some further future proofing against large volumes, the desire to utilize built-in xml functionality for validation, the assurance that a future DataStage developer can pick up and maintain your code, and better management of metadata.

Short of that, if most of your column transformation is upstream, you don't have any schema or concerns about xml validation, and you expect the number of interfaces to grow dramatically, and you have xslt or java expertise available now and in the future, the XMLTransformer or just JavaPack may be the best solution. Feed the transformed columns into either and then use custom xslt or a java class.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
anusha
Premium Member
Premium Member
Posts: 37
Joined: Wed Nov 28, 2007 1:29 am
Location: pune

Post by anusha »

eostic,

Can you brief us on how to create and use Xslt in the Xml Transformer stage to create independent multiple XML files


Thanks..
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

In the Stage Tarsformation settings.
click the radio button for Use trigger column and select a column.
Aquilis
Participant
Posts: 204
Joined: Thu Apr 05, 2007 4:54 am
Location: Bangalore
Contact:

Post by Aquilis »

Verify options on UNIX, where few lists of commands will convert a CSV files into XML file, not even XSLT is required.

Base on your specifications or Requirements, it's betetr to use XSLT.
According to your requirement you don't need any XSLT usage, just try to play with csv2xml command on UNIX.
Aquilis
sivadanam
Participant
Posts: 1
Joined: Fri Jan 10, 2014 4:49 am

Re: Create xml files from flat files using schema file

Post by sivadanam »

Hi Anusha,
Have you achieved the above scenario in singlle job. If so Could you please help me in achieving it am facing issue
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: sivadanam, sorry but you need to start your own post for something like this rather than jump on the end of something similar that's eight years old. That way we know what version you are running and you can fully explain what your requirement and/or issue is that you are having trouble with.

Thanks.
-craig

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