File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How can we convert an xml file to create java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How can we convert an xml file to create java file" Watch "How can we convert an xml file to create java file" New topic
Author

How can we convert an xml file to create java file

Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
Hi,

I've an xml file containing all relevant info relate to class - like class name, methods, attributes. My question is how can I convert that into java file.

Thanks,
Ritu
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
you can use xStream. you can find more information on their homepage


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
John Bengler
Ranch Hand

Joined: Feb 12, 2009
Posts: 133
Hi Ritu,

I would use xlst transformations for this. In fact I already did this to create java classes based on a set of XML files containing a data model, but unfortunately I don't have the code right here, now.

With xslt you can create text files from your XML and it is no problem to create text files that are .java files.
Maybe you can try to google "xslt generate java" to get some examples how to do it.

One hint:

I ran into the problem to need an XSLT processor with enhanced functionality, because I had to write more than one java-file for one XML-file. I think I used XALAN for this, but there should be more XSLT processors with this feature.



John
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How can we convert an xml file to create java file