The goal is to produce the following XML with JAXB
string data
binary data
>
The trick I'm usually using is to create schema with types you want and then use xjc to generate Java classes and see how annotations are used. :) I believe in XML schema proper type mapping for byte[] is 'base64Binary', so creating schema like this:
and running xjc we would get following code generated:
@XmlElementDecl(namespace = "http://www.example.org/NewXMLSchema", name = "aTest")
public JAXBElement createATest(byte[] value) {
return new JAXBElement(_ATest_QNAME, byte[].class, null, ((byte[]) value));
}