• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Creating XML -- Need help

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

We are planning to do a project that involves following steps

1. We have a DTD, a CSV(comma separated value) file.
2. We need to create a XML file reading from the CSV file and it should adhere to DTD given.

My plan to do this is to create a tree using DOM from the DTD and read values from the CSV file and generate the XML file.

Please let me know I am missing anything here.
I am new to XML and related technologies so please forgive me if I have written anything dumb.

Thanks
Kashyap
 
Sheriff
Posts: 28411
102
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
I don't understand what this means:

to create a tree using DOM from the DTD

If it were up to me I would do this:

1. Create an empty DOM.
2. Read values from the CSV file and add elements etc. to the DOM.
3. Write the DOM to a file.
 
Kashyap Hosdurga
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
Thanks a lot for the reply.
Can you please correct me if I am wrong in understanding what you have explained.

If I have to create an empty DOM, I must read the DTD and create empty DOM. (Here empty means we have tags but no values associated to the tags).
Then read the values from the CSV file and write to another file.


Thanks,
Kashyap
 
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

If I have to create an empty DOM, I must read the DTD and create empty DOM.



You are working with some realllly bad assumptions there. A DTD is NOT sufficient to create a DOM - take a look at the DTD for HTML for example. A DTD constrains the structure of a XML document but thats about all you can say.

How much have you done to relate the values in the CSV to the elements in the DOM? For each item in the DTD, do you know which is the corresponding CSV value?

It sounds like you want a DOM with a root element that contains repeating elements, one for each line. Each line element will contain all the CSV data from one line as elements or attributes according to the DTD.

Converting various text formats to XML is a common problem. You may be able to use one of the existing toolkits discussed in my article on XML pipelines. I would suggest looking at the ServingXML toolkit first.

Bill
 
Kashyap Hosdurga
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you William.
You gave me exactly what I was looking for.

Thanks,
Kashyap
 
reply
    Bookmark Topic Watch Topic
  • New Topic