开发者

JAXB - Can XJC compile appinfo into the class structure?

I have a schema which is read by a few different applications for form generation; one of them uses JAXB/XJC to compile its class structure. The schema contains appinfo information for friendly names of fields, eg:

<xs:element name="HomeAddress" type="xs:string">
  <xs:annotation>
    <xs:appinfo>Home address</xs:appinfo>
  </xs:annotation>
</xs:element>

Is there some way to get XJC to开发者_StackOverflow compile this information in?


You can use the Annotate plugin to add arbitrary Java annotations into your schema-derived classes. With this plugin you can manage a syntax like:

<xs:element name="HomeAddress" type="xs:string">
  <xs:annotation>
    <xs:appinfo>
      <ann:annotate xmlns:ann="http://annox.dev.java.net/com.acme.foo">
        <my:Label value="Home address"/>
      </ann:annotate>
    </xs:appinfo>
  </xs:annotation>
</xs:element>

An you'll get something like:

@Label("Home address") // FQCN is com.acme.foo.Label
public String getHomeAddress(...) {}


I am not aware of a way to do this using the XJC tool that comes with the JAXB reference implementation. However, XJC does allow you to create custom plugins that may let you do need to:

  • http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/2.0/jaxb/developPlugins.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜