从Java类生成XML Schema(或相反)

SHi*_*KiT 5 java xsd

我想为我的项目生成一些XML Schema.我有一些Java类,像这样:

package com.fortresswars.entity;

import com.fortresswars.entity.properties.Armor;
import com.jme3.scene.Spatial;

public abstract class Object extends Thing {
    public Armor armor;
    public short hpMax;
    public boolean walkable = false;

    public short hpCurrent;
    public boolean alive;
    public Spatial object;

    public GameObject() {
        this.hpMax = hpMax;
        this.hpCurrent = hpMax;
    }

    public void setAlive(boolean alive) {
        this.alive = alive;
    }

    public void setHpCurrent(short hpCurrent) {
        this.hpCurrent = hpCurrent;
    }

    public void addHpCurrent(short hpToAdd) {
        this.hpCurrent += hpToAdd;
    }
}
Run Code Online (Sandbox Code Playgroud)
package com.fortresswars.entity;

import com.jme3.texture.Image;
import eu.javaspecialists.tools.apt.NoArgsConstructor;

@NoArgsConstructor
public abstract class Thing {
    Image icon;

    public Thing() {
    }
}
Run Code Online (Sandbox Code Playgroud)

我想基于我的项目的那些类生成XML Schema,因此其他开发人员可以基于生成的Schema构建XML文件,他们可以在发送给我之前验证信息.但我不知道什么是最好的,基于类生成XML Schema,或者基于XML Schema生成类.请问,您能指出哪些工具可以做到,以及使用这些方法的优势?

我知道有一个名为JAXB的工具,但我不知道它是否同时完成了这两个工作.