Mato.Duris
Mato.Duris

Reputation: 253

JAXB (new) annotation

If you have some Java class:

@XmlType(namespace="")
@XmlRootElement(name="", namespace="")
public class Car 
{

    // This is some comment
    @XmlElement()
    private long id;
...

And you want to create schema like this (with comment inside schema):

<xs:complexType name="Car ">
  <xs:sequence>
    <xs:documentation> This is some comment</xs:documentation>
    <xs:element name="id" type="xs:long"/>
  </xs:sequence>
</xs:complexType>

Is there way how to configure JAXB? I have think, is there way how to create "new annotation", so my Java class would look like:

@XmlType(namespace="")
@XmlRootElement(name="", namespace="")
public class Car 
{

    @XmlDoc("This is some comment")
    @XmlElement()
    private long id;
...

In other words: can I tell jaxb, that new annotation is important to him and how it should be "parsed" in context.generateSchema (schemaOutputResolver)

(As example: @XmlDoc is new annotation and jaxb should take its value and put in xs: document element)

Upvotes: 2

Views: 97

Answers (1)

bdoughan
bdoughan

Reputation: 148987

Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

This functionality does not currently exist today, but it has been requested before:

There is also an open enhancement request where we are gather the requirements to add this type of feature to MOXy. I would be interested in getting your thoughts on it:

Upvotes: 1

Related Questions