Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB attributes using underscore

I working on JAXB to using java object I am creating xml.But im using javaclass fields Like

qpack_id as attrubute it creating in xml file like qpackId

so how can i use _(underscore) in jaxB please guide me.

xml file should create bellow attibute

<qpack " qpack_id="MB0046_SET4" qpack_name="MB0046">
</qpack>
like image 373
user1906191 Avatar asked Sep 14 '26 14:09

user1906191


1 Answers

Starting from Java Classes

You can use the XmlAttribute annotation to specify a name.

@XmlAttribute(name="qpack_name")
public String getQPackName() {
    return qPackName;
}

Starting from XML Schema

If you are talking about generating Java classes from an XML schema and preserving the _ character in the Java properties names see the answer below for a complete example:

  • How to disable Java Naming Conventions in xjc?
like image 90
bdoughan Avatar answered Sep 16 '26 03:09

bdoughan