現在持っている別の階層を持つ xml-binding を使用して POJO を生成したいと考えています。今、私はこのような xsd を持っています:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://manueldoncel.com" xmlns:tns="http://manueldoncel.com" elementFormDefault="qualified">
<!-- Base element that any element uses / extends -->
<complexType name="baseElement" abstract="true">
<sequence>
<element name="attributes" type="anyType" minOccurs="0" />
</sequence>
<attribute name="id" type="string" />
</complexType>
<complexType name="Square">
<complexContent><extension base="tns:baseElement" /></complexContent>
</complexType>
<complexType name="Triangle">
<complexContent><extension base="tns:baseElement" /></complexContent>
</complexType>
</schema>
このような xjb;
<?xml version="1.0"?>
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jxb:extensionBindingPrefixes="xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:bindings schemaLocation="figures.xsd" node="/xs:schema">
<jxb:globalBindings>
<xjc:simple />
<xjc:superClass name="org.manuel.metadata.Figure"/>
</jxb:globalBindings>
</jxb:bindings>
</jxb:bindings>
しかし、私はこのアプローチでより良い階層を持ちたいと思っています
public abstract class Figure {
// some methods for all the figures
}
public abstract class ThreeSideFigure extends Figure {
.... // some methods for only the Three side Figures
}
したがって、XSD から生成された Triangle POJO は、 からThreeSideFigure
ではなく から拡張する必要がありFigure
ます。
この特定の xsd には 2 つの図しか入れていませんが、もっとたくさん入れることができます。xjb で、complexType はすべて Figure から拡張する必要があるが、ThreeSideFigure から拡張する必要があるのはそのうちのいくつかだけであることを指定できるようにしたいと考えています。
xjb がどのように見えるか知っていますか?