Can JAXB handle multiple “root” elements?

前端 未结 2 1970
伪装坚强ぢ
伪装坚强ぢ 2021-01-13 10:43

I have a schema similar to the following...



         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-13 11:10

    You will need to leverage a factory class annotated with @XmlRegistry (usually called ObjectFactory). That class will contain a create method for each possible root element annotated with @XmlElementDecl. See this article I wrote for more details and examples.

提交回复
热议问题