[Kde-java] XSLT to generate Java sources

Marco Ladermann Marco.Ladermann at gmx.de
Sun May 25 12:11:08 CEST 2003


Hi,

after several month of work (okay, to be honest, I coded only at the weekend), 
I have here some XSLT stylesheets that can read UI files generated by the 
designer and write some Java code.  In the moment I have focused primarily on 
pure Qt elements, but it should be no big thing to also include KDE elements.

In the "bin" subdirectory of the distribution is a shellscript (juic) to start 
the transformation. The script tries to find xsltproc as processor but the 
transformation can also be run with saxon or xalan.

I found some problems with the latest libxml2.so causing an error in some 
for-each. Currently I'm using:

xsltproc -V:
: Using libxml 20503, libxslt 10026 and libexslt 717
: xsltproc was compiled against libxml 20503, libxslt 10026 and libexslt 717
: libxslt 10026 was compiled against libxml 20503
: libexslt 717 was compiled against libxml 20503

The jar files for saxon and xalan are not included in the tar file. They can 
be found at:

saxon: http://prdownloads.sourceforge.net/saxon/saxon6_5.zip?download
(Saxon 7 does not work!) Copy saxon.jar to lib/saxon

xalan: http://xml.apache.org/xalan-j/downloads.html
(Xalan versions less than 2.5.0 do not work) Copy xalan.jar,  xercesImpl.jar, 
and xml-apis.jar to lib/xalan.

Because you can't read arbitrary files with XSLT (only xml) the stylesheets 
ignore any code written for the slots in the xyz.ui.h files. All slots (and 
the class itself) are declared "abstract". If you want a dummy implementation 
for the slots you can run the script with:

juic -abstract false xyz.ui

The usage pattern for the script is
Usage: juic [options] uifile
Where options can be:
    -proc       (xsltproc | xalan | saxon)  : Processor to use, defaults to 
"xsltproc"
    -package    "the.package.for.the.class" : Generates a package declaration
    -abstract   (true | false)              : Slots are declared abstract, 
defaults to "true"
    -images     dir                         : Path to images, defaults to 
"images"
    -os         (unix | msdos | mac)        : Selects newline characters

I hope this stylesheets are of some use for some people out there and  will 
help to popularize the java-bindings.

Any comments to improve the stylesheets are welcome!

Greetings
Marco
-------------- next part --------------
A non-text attachment was scrubbed...
Name: juic.tgz
Type: application/x-tgz
Size: 24438 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-java/attachments/20030525/6b1bb3b5/juic-0001.bin


More information about the Kde-java mailing list