将 XMLElementRefs 转换为具体的 JAVA 类 (JAXB)

时间:2021-01-04 12:49:31

标签: java jaxb xjc

我有一个非常复杂的 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" />

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

0 个答案:

没有答案