• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAXB attribute change

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic