Alin
Alin

Reputation: 14571

Simple XML Schema to POJO converter

I am using Eclipse to build a Android application. Because I use intensely web service I want to be able to create from XML schema some pojos

For instance:

<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/VO.Service.Entities" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/VO.Service.Entities" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="TrackCategories">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Category" nillable="true" type="tns:CategoryInfo" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="TrackCategories" nillable="true" type="tns:TrackCategories" />
  <xs:complexType name="CategoryInfo">
    <xs:sequence>
      <xs:element minOccurs="0" name="CategoryName" nillable="true" type="xs:string" />
      <xs:element minOccurs="0" name="Id" type="xs:int" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="CategoryInfo" nillable="true" type="tns:CategoryInfo" />
</xs:schema>

I want to be able to create the following class

public class CategoryInfo {

 public String CategoryName;
 public Integer Id;

 public String getCategoryName() {
     return CategoryName;
 }


 public void setCategoryName(String value) {
     this.CategoryName =  value;
 }

 public Integer getId() {
     return Id;
 }

 public void setId(Integer value) {
     this.Id = value;
 }

}

As simple as that. No binding, no comments just a plain class. I've tried the JABX plugin for Eclipse but the generated classes have a lot of comments and types that I don't need.

Any solution ?

Upvotes: 1

Views: 1485

Answers (2)

Totoro
Totoro

Reputation: 625

Castor is a heavier lifting solution if you need moar.

Upvotes: 0

zollicoffer
zollicoffer

Reputation: 26

I have used XMLBean by apache - pretty decent classes are generated.

Upvotes: 1

Related Questions