Shared class for child element in JAXB in different xmls/roots

前端 未结 2 797
感动是毒
感动是毒 2021-01-19 17:17

In JAXB when using automatic class generation via xjc from xsd scheme.

alpha.xsd



        
相关标签:
2条回答
  • 2021-01-19 17:57

    You can use an external binding file to indicate that during class generation we wish to use our existing class for the complex type called Document.

    binding.xml

    <jxb:bindings 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
        version="2.1">
    
        <jxb:bindings schemaLocation="beta.xsd">
            <jxb:bindings node="//xs:element[@name='person']/complexType">
                <jxb:class ref="alpha.Person"/>
            </jxb:bindings>
        </jxb:bindings>
    </jxb:bindings>
    

    XJC Call

    xjc -b binding.xml beta.xsd
    
    0 讨论(0)
  • 2021-01-19 18:05

    If namespace of person from A will be equals namespace person from B, that xjc has to generate the correct classes.

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