Showing off X2J I created the following XSD example, which is a simple definition for a contact list which can store connections between the contacts:
<?xml version="1.0" encoding="utf-8"?>
<xs:element name="contact" minOccurs="0" maxOccurs="unbounded">
<xs:element name="friend-of" type="xs:string" minOccurs="0"
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="owner" type="xs:string"/>
You can see I'm using "friend-of" as a list of names. When an XML binding generator creates classes from this, it is likely to produce a
String getFriendOfArray() or something similar.
Check out the corresponding X2J code:
You can see how I can access the Contact instances who are friends with a certain Contact instance immediately; Also, when an XML conforming to this X2J annotated class is parsed, any contact on the "friend-of" list will be checked for existence as part of validation testing, something that (to my humble knowledge) just wouldn't happen in a regular XSD generated class.
I'd love to hear comments, remarks, bashings, suggestions... Anything.
XML to POJOs alpha 0.1
Possible Advantages of X2J: Primary Keys
X2J on the firing line
XML to POJOs Advantages - @Converter