Just demonstrating, my case is more complicated than this so I simplified
it.
Given that I am using the maven-jaxb2-plugin.. does anyone know how to
figure out what version of jaxb I am using?
Thank You,
-Josh
On Sat, Feb 13, 2010 at 2:06 AM, Wolfgang Laun <wolfgang.laun_at_gmail.com>wrote:
> Are you trying to create a binding for a list of String values to a simple
> xs:element value, or are you just demonstrating xjc's (non)handling of
> generics?
>
> For the former, see
> https://jaxb.dev.java.net/tutorial/section_2_2_8-Defining-Other-Lists.html#Defining%20Other%20Listswhere you'll see that using xs:list solves the problem nicely.
>
> -W
>
>
>
> On Sat, Feb 13, 2010 at 9:39 AM, Joshua Royalty <joshua.royalty_at_gmail.com>wrote:
>
>> ####### Schema #########
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <xs:schema
>> elementFormDefault="qualified"
>> targetNamespace="http://test"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns="http://test"
>> >
>> <xs:element name="root" type="rootType" />
>>
>> <xs:complexType name="rootType">
>> <xs:sequence>
>> <xs:element name="items" type="xs:string"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> </xs:schema>
>>
>> ######## Bindings File #############
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <bindings version="2.1"
>> xmlns="http://java.sun.com/xml/ns/jaxb"
>> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> >
>> <bindings schemaLocation="test.xsd" node="/xs:schema">
>> <bindings node="//xs:complexType[@name='rootType']">
>> <bindings node="//xs:element[@name='items']">
>> <property>
>> <baseType>
>> <xjc:javaType adapter="ListAdapter"
>> name="java.util.List<String>" />
>> </baseType>
>> </property>
>> </bindings>
>> </bindings>
>> </bindings>
>> </bindings>
>>
>> ###### Output #####
>>
>> import java.util.List<String>; <--- Problem
>> import javax.xml.bind.annotation.XmlAccessType;
>> import javax.xml.bind.annotation.XmlAccessorType;
>> import javax.xml.bind.annotation.XmlElement;
>> *
>> *
>> *
>> public class RootType {
>>
>> @XmlElement(required = true, type = String.class)
>> @XmlJavaTypeAdapter(ListAdapter.class)
>> protected List<String>items;
>> *
>> *
>> *
>>
>>
>>
>> So.. The problem is pretty obvious, when XJC adds the import for the
>> external type it doesn't remove the generic part. If I switch to
>>
>> <xjc:javaType adapter="ListAdapter" name="java.util.List" />
>>
>> it compiles, but has raw type warnings.
>>
>> This is even a rather trivial example since String is imported by
>> default. What about java.util.List<java.util.Map<String,
>> java.utli.Map<java.util.Set, java.util.List<String>>>> or similar?
>>
>>
>>
>> So... am I missing something? Its similar to
>> https://jaxb.dev.java.net/issues/show_bug.cgi?id=234 .. but not quite,
>> this is a bit more basic than that.
>>
>> I am using the maven-jaxb2-plugin
>> <groupId>org.jvnet.jaxb2.maven2</groupId>
>> <artifactId>maven-jaxb2-plugin</artifactId>
>>
>> Thank You,
>> -Josh
>>
>
>