将xmlelementrefs转换为具体的java类(jaxb)

jmo0nnb3  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(254)

我有一个非常复杂的xml模式,其片段如下所示:

<xs:complexType name="searchLoopType">
    <xs:sequence>
        <xs:element name="loopVarName" type="xs:string"/>
        <xs:choice>
            <xs:sequence>
                <xs:element name="forever" />
                <xs:element name="whileCondition" type="dps:condition" />
            </xs:sequence>
            <xs:sequence>
                <xs:element name="startValue" type="dps:valueType" />
                <xs:element name="endValue" type="dps:valueType" />
                <xs:element name="whileCondition" type="dps:condition" minOccurs="0" />
            </xs:sequence>
            .
            .
            .
            .

它将jaxb类创建为:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "searchLoopType", propOrder = {
    "loopVarName",
    "foreverAndWhileConditionOrStartValue",
    "loopVariables",
    "outputLoopOrOutputGroupOrOutput"
})
public class SearchLoopType {

    @XmlElement(required = true)
    protected String loopVarName;
    @XmlElementRefs({
        @XmlElementRef(name = "startValue", namespace = "http://www.gtt.com/logicalprovisioning/dps/xml/DiscoveryProcessingTable", type = JAXBElement.class, required = false),
        @XmlElementRef(name = "whileCondition", namespace = "http://www.gtt.com/logicalprovisioning/dps/xml/DiscoveryProcessingTable", type = JAXBElement.class, required = false),
        @XmlElementRef(name = "loopList", namespace = "http://www.gtt.com/logicalprovisioning/dps/xml/DiscoveryProcessingTable", type = JAXBElement.class, required = false),
        @XmlElementRef(name = "forever", namespace = "http://www.gtt.com/logicalprovisioning/dps/xml/DiscoveryProcessingTable", type = JAXBElement.class, required = false),
        @XmlElementRef(name = "endValue", namespace = "http://www.gtt.com/logicalprovisioning/dps/xml/DiscoveryProcessingTable", type = JAXBElement.class, required = false)
    })
    protected List<JAXBElement<?>> foreverAndWhileConditionOrStartValue;
.
.
.
.

我试过做一些定制。但不知何故,我无法在标记下生成元素的具体类。你能指导我怎么做吗?我有我的 globalBindings 设置为:

<jxb:globalBindings generateIsSetMethod="true" enableJavaNamingConventions="true" typesafeEnumMemberName="generateName" typesafeEnumBase="xsd:string" fixedAttributeAsConstantProperty="true" generateElementClass="true" choiceContentProperty="true" />

如果你需要更多的信息,请告诉我。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题