我想用我现在拥有的不同层次结构使用xml绑定来生成POJO。 现在我有这样一个一个xsd:带继承的Jaxb POJO生成
<?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生成的三角POJO应该从ThreeSideFigure
而不是从Figure
延伸。
在这个特殊的xsd中,我只放了2个数字,但我可以有更多。我希望能够在xjb中指定所有complexType应该从图中扩展,但只有其中一些应该从ThreeSideFigure扩展。
你知道xjb应该是怎样的吗?