467,077 Members | 1,093 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Java/C++ Code generation via XML and XSLT

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

Jul 20 '05 #1
  • viewed: 3784
Share:
4 Replies
On Mon, 25 Aug 2003 13:40:13 +0200
Thomas Honold <th***********@siemens.com> wrote:
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
Jul 20 '05 #2
On Mon, 25 Aug 2003 13:40:13 +0200,
Thomas Honold <th***********@siemens.com> wrote:
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

Jul 20 '05 #3
Thomas Honold <th***********@siemens.com> writes:
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
Jul 20 '05 #4
Thomas Weidenfeller wrote:
Thomas Honold <th***********@siemens.com> writes:

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.

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.

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by f | last post: by
3 posts views Thread by Henri Sivonen | last post: by
5 posts views Thread by cybernerdsx2 | last post: by
5 posts views Thread by TZESENG | last post: by
3 posts views Thread by alireza6485 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.