[jdom-interest] Class generator

Mattias Jiderhamn mj-lists at expertsystems.se
Thu Dec 22 05:42:55 PST 2011


Have you tried older (pre 1.0) versions of Castor? 
http://castor.codehaus.org/

</Mattias>

----- Original Message -----
Subject: Re: [jdom-interest] Class generator
Date: Thu, 22 Dec 2011 12:31:38 +0000
From: Alexandre Santos <santosam72 at gmail.com>

Yes, you're 100% correct. My problem is that I'm developing a program for a
2001 server that still uses Java 1.2.1 (it's a Oracle 9.0.1 Database...)
and JAXB needs Java 1.5... Yes, i know, BAD TIMES FOR ME :-)

Alex

On Thu, Dec 22, 2011 at 12:09 PM, Brad Cox <bcox at virtualschool.edu> wrote:

 > Regarding "a "tool" that would create those classes automatically from a
 > xsd file"
 >
 > If I understand your question correctly, that's what JAXB does.
 > http://jaxb.java.net/
 >
 >
 > On Thu, Dec 22, 2011 at 5:21 AM, Alexandre Santos 
<santosam72 at gmail.com>wrote:
 >
 >> Hello Rolf,
 >>
 >> I'll do my best to the JDOM community :-)
 >>
 >> This example was compiled with JDOM 1.1.1 and jdk 1.3.1 on a j2se 1.2
 >> eclipse environment, because my Ubuntu 11.10 won't execute the java 
1.2.1
 >> binaries (only my virtual CentOS 2...).
 >>
 >> About your observations: my first post was about asking if there was a
 >> "tool" that would create those classes automatically from a xsd file 
(or a
 >> xml file like EditiX). In my approach, the only "hard" work is to 
copy the
 >> toXML() method to each class. But in the end, you're right :-)
 >>
 >> Maybe a ToDo tool for JDOM :-)
 >>
 >> Alexandre
 >>
 >>
 >> On Thu, Dec 22, 2011 at 2:26 AM, Rolf <jdom at tuis.net> wrote:
 >>
 >>> Hi Alexandre.
 >>>
 >>> Thank you for your feedback. It's nice when people respond the way you
 >>> have.
 >>>
 >>> I have some observations, and a question....
 >>>
 >>> First the questions, in an earlier mail you indicated that you are 
using
 >>> Java 1.2.1. Do you have this running under Java 1.2.1? Are you 
using JDOM
 >>> 1.1.2?
 >>>
 >>> Then the observations....
 >>>
 >>> Just out of interest (and I know that the 'cars2java' example may be a
 >>> massive simplification), but have you considered simply extending 
the JDOM
 >>> classes to get what you want? You may be able to eliminate a complex
 >>> 'model'. It may create other issues, but, you may come up with a 
simpler
 >>> (and perhaps better) solution.
 >>>
 >>> For example, you could declare the class 'Car' to be:
 >>>
 >>> public class Car extends org.jdom.Element {
 >>>
 >>> public Car(String brandname) {
 >>> super("Car");
 >>> setBrand(brandname);
 >>> }
 >>>
 >>> public void setBrand(String brandname) {
 >>> Element brand = getChild("Brand");
 >>> if (brand == null) {
 >>> brand = new Element("Brand");
 >>> // add brand at the beginning of our content....
 >>> addContent(0, brand);
 >>> }
 >>> brand.setText(brandname);
 >>> }
 >>>
 >>> public String getBrand() {
 >>> Element brand = getChild("Brand");
 >>> if (brand == null) {
 >>> return "";
 >>> }
 >>> return brand.getText();
 >>> }
 >>>
 >>> ......
 >>>
 >>> }
 >>>
 >>> Once you have defined 'Car' to extend the JDOM Element, you can create
 >>> Car instances, and add them directly to a root element:
 >>>
 >>> Element cars = new Element("Cars");
 >>> Car renault = new Car("renault");
 >>> renault.setColorRGB("red", "FF0000");
 >>> cars.addContent(renault);
 >>>
 >>> xmlout.output(System.out, cars);
 >>>
 >>>
 >>> Just some thoughts.
 >>>
 >>> Rolf
 >>>
 >>>
 >>>
 >>> On 21/12/2011 6:05 PM, Alexandre Santos wrote:
 >>>
 >>>> Hello Rolf,
 >>>> I've been doing some experiments with a software called EditiX 
that can
 >>>> creates Java classes from a XML file. I've used JDOM on those 
classes to
 >>>> accomplish what I've been trying.
 >>>> The description of the solution I've figured out is here:
 >>>> 
www.alexandre-santos.com/**Cars2Java.html<http://www.alexandre-santos.com/Cars2Java.html>
 >>>> 
<http://www.alexandre-santos.**com/Cars2Java.html<http://www.alexandre-santos.com/Cars2Java.html>
 >>>> >
 >>>>
 >>>> Alexandre
 >>>>
 >>>>
 >>>>
 >>
 >> _______________________________________________
 >> To control your jdom-interest membership:
 >> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
 >>
 >
 >
 >
 > --
 > Cell: 703-594-1883
 > Blog: http://bradjcox.blogspot.com
 > Web: http://virtualschool.edu
 > Manassas VA 20111
 >
 >

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
/MJ



More information about the jdom-interest mailing list