• 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

Need @XMLAttribute with name value even if variable name is same

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please help me out here.
my xsd (only attribute portion not complete)

<xs:element name="E1">
<xs:complextype>
<xs:attribute name="xyz" type="xs:string" />
<xs:attribute name="xyz_abc" type="xs:string" />
</xs:complextype>
</xs:element>

produces JAXB class as (again not complete)

@XmlAttribute
protected String xyz;

@XmlAttribute(name="xyz_abc")
protected String xyzAbc;


but I want the JAXB file to be generated as

@XmlAttribute(name="xyz")
protected String xyz;

@XmlAttribute(name="xyz_abc")
protected String xyzAbc;

What change I have to make in xsd to generate the desired JAXB class.
I m using maven to generate the JAXB classes.
 
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

@XmlAttribute
protected String xyz;


That looks more likely an annotation by hand in object to xml mapping or an annotation generated via any other schema compilation (I have no idea which) tools other than via xjc bundled in the jaxb2 package. By its own, the meaning in practice would be quite the same. I could imagine one would have a hard time in fact to product that exact annotation without name = 'xyz' via xjc.

In any case, you can experiment with an external customisation file to re-iterate the should-be default naming... according the javebean property name.

But that seems a priori quite unnecessary, though.
 
reply
    Bookmark Topic Watch Topic
  • New Topic