xjc for only part of schema

后端 未结 1 511
庸人自扰
庸人自扰 2021-01-12 17:52

We plan to use JAXB for mapping of xml to objects. Our requirement is such that we will be working on only one part of the document (slightly biggish), so we want to only co

相关标签:
1条回答
  • 2021-01-12 18:32

    You can use an external binding file to configure XJC to use an existing class instead of generating one. You can leverage this by pointing to a non-existant class to get JAXB to exclude parts of your XML Schema. In the example below the non-existant class com.example.Fake will be used for the complex type named Foo.

    binding.xml

    <jxb:bindings schemaLocation="yourSchema.xsd">
        <jxb:bindings node="//xs:complexType[@name='Foo']">
            <jxb:class ref="com.example.Fake"/>
        </jxb:bindings>
    </jxb:bindings>
    

    XJC Call

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