JAXB xjc mapping to existing domain objects

后端 未结 1 506
迷失自我
迷失自我 2020-12-05 20:40

I have done a lot of searching and cannot find a concise example of how to map an XML schema to existing domain objects instead of creating brand new ones utilizing xjc<

相关标签:
1条回答
  • 2020-12-05 21:12

    You can use an external binding file to configure XJC to do what you want.

    <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="yourSchema.xsd">
            <jxb:bindings node="//xs:complexType[@name='CustomerOffice']">
                <jxb:class ref="com.blah.domain.CustomerOffice"/>
            </jxb:bindings>
        </jxb:bindings>
    </jxb:bindings>
    

    XJC Call

    xjc -d outputDir -b binding.xml yourSchema.xsd
    
    0 讨论(0)
提交回复
热议问题