This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jaxb marshalling problem

 
James Peter
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

below is my code


and generated xml is


my query is how to avoid creating of element <name>Cath</name>? Please let me know.

Rgds
Peter

 
Jimmy Clark
Ranch Hand
Posts: 2187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Rename 'Name' variable to 'Myname'

2. Delete annotation on 'Myname' variable
 
James Peter
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

thanks for replay. by default jaxb is converting all elements to lowercase.

if i use my variable name as Name then it is converting to <name> which i dont want.
that is why i was testing with annotation. But if I use annotation it is creating 2 elements with "Myname" and also with "name" element.

how to avoid creating of "name" element?

Rgds
Peter
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to avoid creating of "name" element?


A better way to phrase your "issue" might be, how can you disable JAXB's automatic case conversion?

The case of the element names is really a trivial aspect. I suggest that you don't worry about.

Actually, mixed-cased element names has always been discouraged in terms of markup language design. So, the JAXB implementation is actually following a best practice. I doubt that it can be modified.

Aside, the way your Java variables are named is also awkward and should be changed.
 
g tsuji
Ranch Hand
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand the problem correctly, this is how you should do.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic