Java/C++ Code generation via XML and XSLT

T

Thomas Honold

Hi there,

I want to generate C++ or Java code by script, e.g. classes with
getter/setter methods. Someone told me that nowadays it is done with XML
and XSLT. I should use

- XML File which contains classnames and private members
- XSLT to transform them to code files
- XSLT processor which does the conversion

I have no idea of XSLT. What components do I need ? Is there someone out
there who has already done something like that ?

thanks
Thomas
 
A

Andreas Rueckert

Hi there,

I want to generate C++ or Java code by script, e.g. classes with
getter/setter methods. Someone told me that nowadays it is done with XML
and XSLT. I should use

- XML File which contains classnames and private members
- XSLT to transform them to code files
- XSLT processor which does the conversion

I have no idea of XSLT. What components do I need ? Is there someone out
there who has already done something like that ?

I don't think, you really want to do this. Those XSLT sheets grow awfully
complex, since XSLT has not the power of a programming language in some
areas. There's a Sourceforge project called XSL4XMI with some sheets in
CVS, that generate Java from a XMI file (UML design written as XML file).

Ciao,
Andreas
 
K

karl wettin

Hi there,

I want to generate C++ or Java code by script, e.g. classes with
getter/setter methods. Someone told me that nowadays it is done with
XML and XSLT. I should use

- XML File which contains classnames and private members
- XSLT to transform them to code files
- XSLT processor which does the conversion

I have no idea of XSLT. What components do I need ? Is there someone
out there who has already done something like that ?

You can generate Java from UML class diagram using Silvertejp, see
http://silvertejp.dnsalias.net/snigelwiki/snigel

ArgoUML also features some code generation, not as good, but both for
C++ and Java.



karl
 
T

Thomas Weidenfeller

Thomas Honold said:
I want to generate C++ or Java code by script, e.g. classes with
getter/setter methods.

It very much depends on what type of code, and how many you want to
generate from which type of available input.
Someone told me that nowadays it is done with XML
and XSLT.

Is it? I don't care :)

Depending of what needs to be done, I would use:

- for simple tasks a simple shell script

- a macroprocessor like m4 for generating code based on macros
"inlined" in some Java source.

- awk for generating code completely from some simple home-made
description language

- perl for generating code from some less simple, home-made
description language

- Special tools for specific tasks, e.g. a parser generator for
building some parser.

A shell is a Unix command line interpreter which usually allows some
form of scripting (shell scripts are extremely powerful compared to
DOS/Windows BAT/CMD files). M4 and awk are classic Unix text processing
tools, perl is a Unix scripting language. Ports are available for other
platforms, too.

/Thomas
 
J

Jon A. Cruz

Thomas said:
Is it? I don't care :)

Depending of what needs to be done, I would use:

- for simple tasks a simple shell script

- a macroprocessor like m4 for generating code based on macros
"inlined" in some Java source.


In the past, I've done this for C++.

For a project with GUI widgets, I did a base XML source file with
information on the API, then XSL stylesheets to create a users guide, an
implemntors guide, and a test program to ensure the documentation was in
sync with the library.

For something like that, XML was most appropriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,294
Messages
2,571,518
Members
48,225
Latest member
JasminOrta

Latest Threads

Top