Can JAXB handle multiple “root” elements?

前端 未结 2 1972
伪装坚强ぢ
伪装坚强ぢ 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.

    0 讨论(0)
  • 2021-01-13 11:10

    I am a newbee to jaxb. I had one doubt regarding jaxb

    @XmlElementDecl(namespace = "http://mtop/nra/xsd/tca/v1", name = "thresholdCrossingAlert", substitutionHeadNamespace = "http://mtop/fmw/xsd/cei/v1", substitutionHeadName = "commoneventInformation")
    

    This is the annotation where I am getting the exception as

    "java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions" 
    

    ThresholdCrossingAlert.class is extending the class EventInformationType.class and EventInformationType.class is extending the class CommonEventInformation.class inturn,

    Is this any problem with my annotation definition or error in Initializing the JaxbContext.

    0 讨论(0)
提交回复
热议问题