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.
Joined: Sep 19, 2005
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.
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.