Xsd JAXB:xjc和派生类型属性的固定值

Xsd JAXB:xjc和派生类型属性的固定值,xsd,jaxb,xjc,Xsd,Jaxb,Xjc,我正在尝试创建一个具有类型层次结构的xsd。 我希望归档的是子类型用特定的值填充基类型的属性。 这是我最好的结果: <xs:complexType name="base_type"> <xs:attribute name="att" use="required" type="xs:string" /> </xs:complexType> <xs:complexType name="type1_t"> <xs:complexCo

我正在尝试创建一个具有类型层次结构的xsd。 我希望归档的是子类型用特定的值填充基类型的属性。 这是我最好的结果:

<xs:complexType name="base_type">
    <xs:attribute name="att" use="required" type="xs:string" />
</xs:complexType>
<xs:complexType name="type1_t">
    <xs:complexContent>
        <xs:restriction base="base_type">
            <xs:attribute name="att" fixed="value1" use="required" type="xs:string" />
        </xs:restriction>
    </xs:complexContent>
</xs:complexType>
<xs:complexType name="type2_t">
    <xs:complexContent>
        <xs:restriction base="base_type">
            <xs:attribute name="att" fixed="value2" use="required" type="xs:string" />
        </xs:restriction>
    </xs:complexContent>
</xs:complexType>
我早就料到了

{
  @Override public String getAtt() { return "value1"; }
}
?? 这就是(几乎)当类型由自身生成(即不是作为基类型的扩展)时生成的内容

我做错什么了?我想做的是不可能的吗

我的目标是从xsd自动生成所有java代码;否则,我认为实现这一点的方法是在为每个类创建的ObjectFactory方法中手动编写固定值。但是,我需要防止每次生成ObjectFactory

有什么提示吗?提示?想法

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "type1_t")
public class Type1T extends BaseType { }
{
  @Override public String getAtt() { return "value1"; }
}