• 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

How can we convert an xml file to create java file

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use xStream. you can find more information on their homepage
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic