users@jaxb.java.net

tag with attributes and text content as a field

From: Benjamin Reed <rangerrick_at_gmail.com>
Date: Sat, 12 Sep 2009 10:45:59 -0400

I could have sworn I've seen a way to do this before but I can't for
the life of me find it. I'd like to output XML with JAXB in a
particular format, ie:

  <foo type="bar">baz</foo>

If my class looks like this:

@XmlRootElement(name="foo")
@XmlAccessorType(XmlAccessType.FIELD)
public class Foo {
  @XmlAttribute
  String type;
  @XmlElement
  String value;
}

I end up with this XML:

  <foo type="bar">
    <value>baz</value>
  </foo>

Does anyone know how to make the "value" field end up as the contents of foo?

-- 
Benjamin Reed a.k.a. Ranger Rick
Fink, KDE, and Mac OS X development
Blog: http://www.raccoonfink.com/
Music: http://music.raccoonfink.com/