Java/C++ Code generation via XML and XSLT

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Honold

    #1

    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

  • karl wettin

    #2
    Re: Java/C++ Code generation via XML and XSLT

    On Mon, 25 Aug 2003 13:40:13 +0200
    Thomas Honold <thomas.honold@ siemens.com> wrote:
    [color=blue]
    > 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 ?[/color]

    You can generate Java from UML class diagram using Silvertejp, see


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



    karl

    Comment

    • Andreas Rueckert

      #3
      Re: Java/C++ Code generation via XML and XSLT

      On Mon, 25 Aug 2003 13:40:13 +0200,
      Thomas Honold <thomas.honold@ siemens.com> wrote:
      [color=blue]
      >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 ?[/color]

      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

      Comment

      • Thomas Weidenfeller

        #4
        Re: Java/C++ Code generation via XML and XSLT

        Thomas Honold <thomas.honold@ siemens.com> writes:[color=blue]
        > I want to generate C++ or Java code by script, e.g. classes with
        > getter/setter methods.[/color]

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

        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

        Comment

        • Jon A. Cruz

          #5
          Re: Java/C++ Code generation via XML and XSLT

          Thomas Weidenfeller wrote:[color=blue]
          > Thomas Honold <thomas.honold@ siemens.com> writes:
          >
          >[color=green]
          >>Someone told me that nowadays it is done with XML
          >>and XSLT.[/color]
          >
          >
          > 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.[/color]


          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.

          Comment

          Working...