Add attribute in an xml via notation

0

I have the following structure in java

package xxxxx.entities;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="ListarApolice")
public class RetornoListarDadosApolice {

    public RetornoListarDadosApolice(){

    }


    @XmlElement(name = "codigoCritica", required = true)
    public Short codigoCritica;

    @XmlElement(name = "descricaoCritica")
    public String descricaoCritica;

    @XmlElementWrapper(name = "ListarApoliceCollection")
    @XmlElement(name = "ApoliceListarDadosApolice", type=ApoliceListarDadosApolice.class)
    public List<ApoliceListarDadosApolice> apoliceListarDadosApolice;


    public Short getCodigoCritica() {
        return codigoCritica;
    }


    public void setCodigoCritica(Short codigoCritica) {
        this.codigoCritica = codigoCritica;
    }


    public String getDescricaoCritica() {
        return descricaoCritica;
    }

    public void setDescricaoCritica(String descricaoCritica) {
        this.descricaoCritica = descricaoCritica;
    }

    public List<ApoliceListarDadosApolice> getApoliceListarDadosApolice() {
        return apoliceListarDadosApolice;
    }

    public void setApoliceListarDadosApolice(
            List<ApoliceListarDadosApolice> apoliceListarDadosApolice) {
        this.apoliceListarDadosApolice = apoliceListarDadosApolice;
    }
}

I need to add attributes like this example in the image:

All the solutions I got were to transform each element into a class and within that class the attribute ... but in that I'm going to have to create 70 or more classes for that .. because xml is giant ... would have a solution more viable with less code than this?

    
asked by anonymous 07.11.2018 / 17:57

0 answers