XJC does not generate jaxb binding basetType class

31 Views Asked by At

I want to generate a hashmap to hold the elements under an element. So that I can fetch or update these elements in a single call. So I tried generating a binding file for this. But it never generates the classes which I am looking for. I am expecting classes "MappingMap" and "MappingMapAdapter" to be generated under package "pkg.beans", but these two are not getting generated. Remaining jaxb classes are created properly. I am using ant script to run the xjc.

Here are the details:

configuration.xsd

<xs:element name="mapping_data">
    <xs:complexType>
        <xs:sequence>
            <xs:element minOccurs="0" name="mapping" type="test:MappingModeller"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="MappingModeller">
    <xs:sequence>
        <xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="key" type="xs:string"/>
                    <xs:element name="value" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>

binding.xjb

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1">
    <jaxb:bindings schemaLocation="..\..\..\..\..\xsd\configuration.xsd">
        <jaxb:bindings node="//xs:element[@name='mapping_data']//xs:element[@name='mapping']">
            <jaxb:property>
                <jaxb:baseType name="pkg.beans.MappingMap&lt;String,String&gt;" />
            </jaxb:property>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

I am using ant script to generate the jaxb classes from the xsd.

<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
    <classpath>
        <fileset dir="${dir.jaxb.home}/mod/" includes="*.jar"/>
    </classpath>
</taskdef>

<target name="generate_jaxb_parser_for_schema">
    <xjc destdir="${dir.generated.jaxb}" package="pkg.beans" removeOldOutput="yes">
        <schema dir="${dir.xsd}" includes="configuration.xsd"/>
        <binding dir="${dir.jaxb.bindings}" includes="binding.xjb"/>
        <produces dir="${dir.generated.jaxb}/pkg/beans" includes="*"/>
        <arg value="-no-header"/>
        <arg value="-encoding"/>
        <arg value="UTF-8"/>    
    </xjc>
</target>

This is the snippet of MappingData.java which has unresolved "MappingMap":

    @XmlRootElement(name = "mapping_data")
    public class MappingData {

        @XmlElement(type = MappingModeller.class)
        protected MappingMap<String, String> mapping;

Am I doing something wrong? Please help.

0

There are 0 best solutions below