久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

JaxB 重命名具有重復名稱的類

JaxB rename class with duplicate name(JaxB 重命名具有重復名稱的類)
本文介紹了JaxB 重命名具有重復名稱的類的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我必須使用包含以下片段的架構,其中名稱 object 重復.

I have to use a schema which contains the following snippet where the name object is duplicated.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:complexType name="param_object_type">
        <xs:sequence>
            <xs:element name="object" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="object" minOccurs="0" maxOccurs="unbounded">
                </xs:sequence>
            </xs:complexType>
        </xs:sequence>
    </xs:complexType>

</xs:schema>

Jaxb 最初很樂意導入它,但由于 Object 類被聲明了兩次,因此無法編譯源代碼.

Jaxb was originally happy to import this, but would fail to compile the sources since the Object class was declared twice.

我添加了 globalBindings 選項 localScoping="toplevel" 現在這會導致以下編譯時錯誤:

I added globalBindings option localScoping="toplevel" and this now leads to the following compile time error:

org.xml.sax.SAXParseException;systemId:具有相同名稱jaxb.Object"的類/接口已在使用中.使用類自定義來解決此沖突.

所以我嘗試添加自定義綁定來重命名對象之一,jaxb:classjaxb:property.兩者都產生相同的錯誤.

So I tried adding a custom binding to rename one of the objects, jaxb:class and jaxb:property. Both produce the same error.

如果有幫助,這是我的綁定文件:

If it helps, here is my bindings file:

<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jaxb:bindings>
        <jaxb:globalBindings generateElementProperty="false" fixedAttributeAsConstantProperty="true" choiceContentProperty="true" localScoping="toplevel"/>
    </jaxb:bindings>
    <jaxb:bindings  schemaLocation="../xsd/NodeSchema.xsd" node="/xs:schema">
        <jaxb:bindings node="/xs:schema/xs:complexType[@name='param_object_type']/xs:sequence/xs:element[@name='object']">
            <jaxb:class name="object2"/>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

如何確保其中一個實例被重命名而另一個保持不變?

How can I make sure that one of these instances gets renamed and the other is left intact?

推薦答案

正確的復雜類型.. xs:element

XSD

<xs:complexType name="param_object_type">
    <xs:sequence>
        <xs:element name="object" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="object" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>

綁定

<jxb:bindings node="http://xs:schema//xs:complexType[@name='param_object_type']//xs:sequence//xs:element[@name='object']//xs:complexType//xs:sequence//xs:element[@name='object']">
    <jxb:class name="object2" />
</jxb:bindings>

ParamObjectType.java

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "param_object_type", propOrder = {
    "object"
})
public class ParamObjectType
    implements Serializable
{

    private final static long serialVersionUID = 2L;
    protected List<ParamObjectType.Object> object;

    /**
     * Gets the value of the object property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the object property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getObject().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link ParamObjectType.Object }
     * 
     * 
     */
    public List<ParamObjectType.Object> getObject() {
        if (object == null) {
            object = new ArrayList<ParamObjectType.Object>();
        }
        return this.object;
    }


    /**
     * <p>Classe Java per anonymous complex type.
     * 
     * <p>Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
     * 
     * <pre>
     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="object" type="{http://www.w3.org/2001/XMLSchema}anyType" maxOccurs="unbounded" minOccurs="0"/>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "object"
    })
    public static class Object
        implements Serializable
    {

        private final static long serialVersionUID = 2L;
        @XmlElementRef(name = "object", type = ParamObjectType.Object.Object2 .class, required = false)
        protected List<ParamObjectType.Object.Object2> object;

        /**
         * Gets the value of the object property.
         * 
         * <p>
         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a <CODE>set</CODE> method for the object property.
         * 
         * <p>
         * For example, to add a new item, do as follows:
         * <pre>
         *    getObject().add(newItem);
         * </pre>
         * 
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link ParamObjectType.Object.Object2 }
         * 
         * 
         */
        public List<ParamObjectType.Object.Object2> getObject() {
            if (object == null) {
                object = new ArrayList<ParamObjectType.Object.Object2>();
            }
            return this.object;
        }

        public static class Object2
            extends JAXBElement<java.lang.Object>
        {

            protected final static QName NAME = new QName("", "object");

            public Object2(java.lang.Object value) {
                super(NAME, ((Class) java.lang.Object.class), ParamObjectType.Object.class, value);
            }

            public Object2() {
                super(NAME, ((Class) java.lang.Object.class), ParamObjectType.Object.class, null);
            }

        }

    }

}

這篇關于JaxB 重命名具有重復名稱的類的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 亚洲国产精品久久久久久 | 久久剧场| 日韩在线精品强乱中文字幕 | 超碰免费在线 | 亚洲国产精品一区二区三区 | 一区二区三区四区视频 | 亚洲91精品| 99精品国产一区二区三区 | 岛国av免费看 | 精品久久久久久亚洲精品 | 欧美一区不卡 | 国产区在线观看 | 精品国产乱码久久久久久丨区2区 | 国产永久免费 | 亚洲精品在线国产 | 亚洲国产成人精品久久久国产成人一区 | 韩国精品在线 | 97精品国产| 国产乱码精品一区二区三区忘忧草 | 日韩成人免费 | 日韩午夜网站 | 亚洲欧美v | 欧美一区二区三区免费在线观看 | 国产电影一区二区 | 美女视频黄色片 | 成人国产精品久久久 | 亚洲精品自在在线观看 | 男女一区二区三区 | 欧美日韩综合一区 | 在线 丝袜 欧美 日韩 制服 | 亚洲综合一区二区三区 | 日韩久久网| 91精品国产91久久久久久密臀 | 特级做a爱片免费69 精品国产鲁一鲁一区二区张丽 | 成人av网站在线观看 | 国产精品自产拍在线观看蜜 | 色吊丝2| 成人妇女免费播放久久久 | 激情福利视频 | 成人av播放| 欧美日韩国产在线观看 |