highsource / jaxb2-annotate-plugin

Add arbitrary annotations to JAXB classes.
Other
72 stars 28 forks source link

Please support dynamic content of annotations #53

Closed Hubbitus closed 5 years ago

Hubbitus commented 5 years ago

My intention provide bindings allowing me generate class annotations from XML annotation .

For example by default class generated like:

/**
 * Attachment document.
 * 
 * <p>Java class for TAttachment complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="TAttachment"&gt;
 *   &lt;complexContent&gt;
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
 *       &lt;sequence&gt;
 *         &lt;element name="desc" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt;
 *         &lt;element name="fileDesc" type="{http://rosreestr.ru/services/v0.1/commons/Documents}TFileDesc" minOccurs="0"/&gt;
 *         &lt;element name="receivedInPaper" type="{http://rosreestr.ru/services/v0.1/commons/Documents}TReceivedInPaper" minOccurs="0"/&gt;
 *       &lt;/sequence&gt;
 *     &lt;/restriction&gt;
 *   &lt;/complexContent&gt;
 * &lt;/complexType&gt;
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "TAttachment", namespace = "http://rosreestr.ru/services/v0.1/commons/Documents", propOrder = {
    "desc",
    "fileDesc",
    "receivedInPaper"
})
public class TAttachment{

This is generated from xsd fragment like:

    <xs:complexType name="TAttachment">
        <xs:annotation>
            <xs:documentation>Attachment document.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
...

I want have Attachment document. available at runtime, so generate class like:

@Documentation("Attachment document.")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "TAttachment", namespace = "http://rosreestr.ru/services/v0.1/commons/Documents", propOrder = {
    "desc",
    "fileDesc",
    "receivedInPaper"
})
public class TAttachment{

That required for classes and properties.

Hubbitus commented 5 years ago

I've wrote my XJC-plugin exactly for that purpose.

highsource commented 5 years ago

This is the right approach. :)