You would need to use the Java I/O libraries for reading contents of text files and writing contents of text files. And you most likely would need to use Java's Regular Expression libraries for pattern matching and such. Aside, Perl is actually a much stronger language than Java for this type of task.
Joined: May 06, 2003
I agree. Some customization is needed. Thank you.
Joined: Apr 16, 2008
Sounds good. At this point, there is nothing to "customize" however. In order to create a data conversion program to create XML documents, you would use the existing Java libraries in conjunction with your own code. Here you are not creating any type of "customization" of existing Java libraries and your portion does not exist so it cannot be "customized."
Once you create the application, then you can think of "customizing" it for additional business requirements that may come in the future.
In the past I have used the rather obscure technique of taking an identity transformation and feeding it a stream of SAX events. When you use a SAX parser it passes a stream of SAX events to your ContentHandler, which means in practice that it calls your ContentHandler's startDocument and startElement and characters methods (etc) in the right order. My technique is to turn that around. Here's a brief outline extracted from some of my code:
This is just a crude outline, notice that I've hard-coded constants which would normally be passed to the code as method parameters, but it is working code which outputs a simple XML document.
An advantage of this is that it leverages the knowledge of the built-in Java classes so that you don't have to concern yourself with escaping of ampersands and quoting of attributes and all of that tedious stuff.