Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Premaa Kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
g tsuji
Ranch Hand
Posts: 672
3
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic