users@jaxb.java.net

_at_XmlAttribute/_at_XmlValue need to reference a Java type that maps to text

From: Shelley <randomshelley_at_gmail.com>
Date: Thu, 2 Aug 2007 09:02:44 -0500

I need an @XmlValue to be an Object (xs:anyType), however, the following
exception occurs when marshalling my jaxb-annotated classes:

    com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of
IllegalAnnotationExceptions
    @XmlAttribute/_at_XmlValue need to reference a Java type that maps to text
in XML.

Here are the basic annotations:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "argument")
    public class Argument {

        @XmlAttribute(name = "type")
        protected String type;

        @XmlValue
        protected Object value;

        ...
    }

(These annotations were originally created via xjc.)

The desired output is as follows:

    <argument type="arg1.type" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="
http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">
        test
    </argument>

Any suggestions would be appreciated.