2

I am trying to add an attribute using javax.xml.bind.annotation to a simple type (String in this case)

so i want this

<myObj><stuff foo="bar">data</stuff></myObj>

if stuff is a string inside of 'myObj' , is this possible?

I know that this is most likely easy i was just having trouble finding an example that added an attribute to a non-complex type.

thanks so much!

nemisis enforcer
  • 349
  • 3
  • 18
  • Similar to this question here? http://stackoverflow.com/questions/3666467/how-can-i-add-xml-attributes-to-jaxb-annotaded-class-xmlelementwrapper – pacman Jun 14 '12 at 21:44
  • The following may help: http://blog.bdoughan.com/2011/06/jaxb-and-complex-types-with-simple.html – bdoughan Jun 14 '12 at 23:30
  • What value has 'stuff'? "data"? or "bar"? What is 'foo' here? – Ilya Jun 15 '12 at 10:57
  • sorry that it was a bit vague, but stuff i want to be a string in my bean, but the foo i would like to be an attribute of that string, but i would like to do it without creating an additional object of type stuff that would contain just a string and one attribute. – nemisis enforcer Jun 18 '12 at 13:14

1 Answers1

0

I hate leaving things hanging... Basically what i was trying to do was to add an attribute to a String who was residing in the class , but what i had to do was to wrap that string into a pojo who had an xmlvlaue as well as other members for the attributes.

thanks

nemisis enforcer
  • 349
  • 3
  • 18