X2J in action
Okay, so its not the highlight of the framework, but its something. Just an example to show that it's working, both for you and for myself.
You can download the source, and I'll post here the Recipe and Step classes (the only classes in the application except the Form). There was no XSD needed to read or write the XML document, and as you can see, it's perfectly readable by any application.
[Image unavailable: /wp-content/thumb-Picture3.png]
// lang java
@Name("three-step-recipe")
@Root
public class Recipe {
private int prepTime;
private String name;
private Step[] steps;
@Attribute
public int getPreparationTime() {
return prepTime;
}
@Attribute
@Mandatory
public String getName() {
return name;
}
@FixedSequence(3)
@Element
public Step[] getSteps() {
return steps;
}
}
}
@ComplexType
public class Step {
private String title;
@Attribute
@Mandatory
public String getTitle() {
return title;
}
}
Obviously there are setters to complement the getters. I removed them so that the page won't be too stuffed with code.
And again, you can find the X2J project here.
PS until I manage to instsall this code highlighter, the code text might appear dull and small. Apologies ahead.
Comments (2)