aspose file tools*
The moose likes Distributed Java and the fly likes JAXB attribute change Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JAXB attribute change" Watch "JAXB attribute change" New topic
Author

JAXB attribute change

Shilpa Nandiv
Greenhorn

Joined: Oct 29, 2012
Posts: 6
Hi ,

Ia m using using JAXB to create xml file.So I want to create attribute using underscore(_). If I took qpack_name as field name its taking qpackName,But requirement is I need qpack_name like this so please tell how to do.
<qpack qtnrid="319" duration="120" qpack_id="MB0041_SET5" qpack_name="MB0041"><passages><passage id="1595"><label><![CDATA[<p style="text-align:center;hyphenate:auto;font-family:Calibri;font-size:10pt;"><span>Passage Label 1</span></p>]]></label>

Thanks

svn
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 535
    
    3
If I took qpack_name as field name its taking qpackName,But requirement is I need qpack_name like this so please tell how to do.

In the class, under the assumption that you use the default naming, Qpack, you have a field qpack_name. You should already have an annotation @XmlAttribute such as on its getter. You can then change the annotation of it adding name you want it to appear in the xml document.

Variants are possible according to your concrete set up. But as long as the name for the xml is specified like qpack_name, the variable name is quite arbitrary: you don't even need to name it qpack_name (it might look awkward in the bean...) in the class.
 
Consider Paul's rocket mass heater.
 
subject: JAXB attribute change