• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Suggestion required

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have to develop a system that would transform file from one format to another format( say CSV to fixed width). I have taken the following approach to implement it
CSV -> rules.xml ( CSV field to some column name mapping) ->XSLT tranformation-> targetfile in xml-> Fixed width file

Now, the rules.xml file is the one that specifies what are the index that start begin and end of data Say if file is Pankaj,123,Physics then rules would specify details that 0 to 5 is name 7 to 9 is roll number etc, so that i can generate XML file out of that CSV.

Would like to have inputs from you people. Earlier i though that the details of column would be specified in the schema, but then i believe that we cannot use schema and apply it on CSV to generate XML. This is mojor confusion that i can do this or no

Thanks in advance
Pankaj Tiwari
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, a schema used is for validating an XML file, not for specifying how it might be transformed. This information would be part of the XSLT stylesheet. But you should not have to specify where fields start in the CSV - that's what the "C" of CSV is for - it indicates field boundaries.

For this problem, I wouldn't use XML or XSLT. There are any number of libraries that can read CSV and present the information in an object model, from where you can generate the output any way you want. That seems easier than an XSLT approach (which is anyway not exactly straightforward for non-XML input).
 
Pankaj Tiwari
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Ulf,
The reason why i wanted to involve XML in between is that that i got to convert CSV to some other format and the order in which data is displayed in that other format would be defined by the user. So i belive in this case XSLT would be a simple way to do so. And also its like now i gotto convert CSV, later on there could be some other formats or a database involved.
 
Pankaj Tiwari
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
something like sourcefile-> transformation engine -> target file.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, what kind of "inputs" are you looking for? You seem to have a basic architecture (convert CVS to XML, use XSLT to transform it to something else). Without knowing anything about the "something else" it's pretty hard to comment.
 
Pankaj Tiwari
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
currently CSV and pipe seperated files. There would be applications that would be contineously generating those files and my application would be reading it and converting it into xml which would be used by another application as input
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you look at this "Pipeline" processing toolkit.

Bill
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic