Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add annotation to simpleContent (with extension) #66

Open
MDesharnaisX opened this issue Feb 11, 2021 · 1 comment
Open

Add annotation to simpleContent (with extension) #66

MDesharnaisX opened this issue Feb 11, 2021 · 1 comment

Comments

@MDesharnaisX
Copy link

MDesharnaisX commented Feb 11, 2021

Hi,
I have an issue that requires me to add the @XmlValueExtension annotation to an object attribute that is generated by a Simple content extending double.
I can't find how to bind this in my xjb file.
My XSD looks like :

<xs:complexType name="level1">
        <xs:sequence>
            <xs:element name="level2" minOccurs="0">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="level3" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                                <xs:simpleContent>
                                    <xs:extension base="xs:double">
                                        <xs:attribute name="level4" type="xs:string" use="required"/>
                                    </xs:extension>
                                </xs:simpleContent>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

I get the following classes

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "level1")
public class Level1
    implements Serializable
{

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "level2")
    public static class Level2
        implements Serializable
    {

        protected UIList<Level1.Level2.Level3> level3 = new UIArrayList<Level1.Level2.Level3>();

        public UIList<Level1.Level2.Level3> getLevel3() {
            return this.level3;
        }

        @XmlAccessorType(XmlAccessType.FIELD)
        @XmlType(name = "level3")
        public static class Level3
            implements Serializable
        {
            @XmlValue
            @XmlSchemaType(name = "double")
            protected Value<Double>value;
            @XmlAttribute(name = "level4", required = true)
            protected Value<Double> level4;

            /**
             * Obtient la valeur de la propriété value.
             * 
             * @return
             *     possible object is
             *     {@link String }
             *     
             */
            public Value<Double>getValue() {
                return value;
            }

            /**
             * Définit la valeur de la propriété value.
             * 
             * @param value
             *     allowed object is
             *     {@link String }
             *     
             */
            public void setValue(Value<Double>value) {
                this.value = value;
            }

        }

    }

}

I would like to add the annotation @XmlValueExtension to the protected Valuevalue;

I've tried the following :

<jaxb:bindings node="xs:complexType[@name='level1']/xs:sequence/xs:element[@name='level2']/xs:complexType/xs:sequence/xs:element[@name='level3']/xs:complexType/xs:simpleContent">
            <annox:annotate target="class">@java.lang.SuppressWarnings("something")</annox:annotate>
        </jaxb:bindings>

But I can only annotate the class, not the value attribute.

Thanks for the help

@laurentschoelens
Copy link
Collaborator

Hi @MDesharnaisX

For reference, another issue have been linked to this one with same problem and the user found the way to acheive the annotation with some adjustments to xjb bindings file.

We are also moving this repo to the maven-jaxb2-plugin repository, now renamed jaxb-tools.
You'll find a new 2.0.5 version of this plugin with same groupId for all artifacts.
Also, documentation from unavailable confluence have been restored in the wiki

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants