When using xjc, a bindings.xjb and a xsd file are provided. I have a enumeration inside my xsd, called "EnumType", which contains a single element called "I24". Jaxb creates "" with a "I_24" element and so


Throws exception.


I have the following xsd:

<xs:simpleType name="EnumType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="I24" />

And i have the following bindings.xjb:

<jaxb:bindings xmlns:jaxb="" xmlns:xs="" xmlns:xjc="" xmlns:xsi="" xmlns:annox="" xsi:schemaLocation="" jaxb:extensionBindingPrefixes="xjc annox" version="2.1">

    <jaxb:bindings schemaLocation="xsdFile.xsd">
        <jaxb:bindings node="//xs:simpleType[@name='EnumType']/xs:restriction/xs:enumeration[@value='I24']">
            <jaxb:typesafeEnumMember name="I24"/>


This makes my enum have a member called "I24" inside my java code and i like it. BUT i need this kind of thing for all the future cases when a new enum member must be added, for example "X24".

I want all the generated enumeration names to be EXACTLY as they are specified inside my XSD, without providing all of them inside my xjb file.

Also, my generated classes must implement Serializable, so i made a xjb file which is as follows and works for this last requirement. I have to extend this file in order to accomplish enumeration name forcing:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="" xmlns:xs="" xs:schemaLocation="" jaxb:version="2.0">

    <jaxb:globalBindings fixedAttributeAsConstantProperty="true">
        <jaxb:serializable uid="1" />

0 Answers