How to rename XML attributes from Java classes using JAXB annotations?

Blackduck

New Member
I have this class defintion:\[code\]@XmlRootElementpublic class RssRoot {private String _version;private String _xmlns_content;@XmlAttribute()public String get_version() { return _version;}@XmlAttribute()public String get_xmlns_content() { return _xmlns_content;}public void set_version(String version) { _version = version; } public void set_xmlns_content(String xmlnsContent) { _xmlns_content = xmlnsContent; } public RssRoot() { super(); this._version = "2.0"; this._xmlns_content = "http://purl.org/rss/1.0/modules/content/"; }}\[/code\]And it generates this xml:\[code\]<rssRoot xmlnsContent="http://purl.org/rss/1.0/modules/content/" version="2.0"/>\[/code\]However, I need to rename \[code\]xmlnsContent\[/code\] to \[code\]xmlns:content\[/code\], and \[code\]rssRoot\[/code\], to \[code\]rss\[/code\]. How can I do this?I tried with \[code\]@XmlAttribute(name = "xmlns:content")\[/code\] above the getter and near to the property declaration, but no luck. The thing fails with this message:\[quote\] Root Exception stack trace: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnno tationExceptions Class has two properties of the same name "_xmlns_content" this problem is related to the following location: RssRoot\[/quote\]What else can I do?
 
Top