Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9211669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:21:00+00:00 2026-06-18T01:21:00+00:00

My enum class @XmlType @XmlEnum(Integer.class) public enum Error { @XmlEnumValue(1) ENUM_VALUE_1(1, some string 1,

  • 0

My enum class

@XmlType
@XmlEnum(Integer.class)
public enum  Error {

 @XmlEnumValue("1")
    ENUM_VALUE_1(1, "some string 1", "some string 1"),
 @XmlEnumValue("2")
    ENUM_VALUE_2(2, "some string 2", "some string 2");

  private Error(int errorCode, String msgKey, String message) {
    this.errorCode = errorCode;
    this.msgKey = msgKey;
    this.message = message;
 }
}

Generated xsd

<xs:simpleType name="error">
   <xs:restriction base="xs:int">
     <xs:enumeration value="1"/>
     <xs:enumeration value="2"/>
   </xs:restriction>
</xs:simpleType> 

binding I am using

 <jaxb:bindings schemaLocation="schema.xsd">
     <jaxb:bindings node="//xs:simpleType[@name='error']">
         <jaxb:typesafeEnumClass ref="packageName.Error" />
     </jaxb:bindings>
 </jaxb:bindings>

The problem is there is no enum file is getting generated. I am using “maven-jaxb2-plugin” for code generation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:21:01+00:00Added an answer on June 18, 2026 at 1:21 am

    By default a JAXB (JSR-222) implementation will not create a Java enum for XML enumerations that start with numeric values. You can use an external binding file to cause an enum to be generated.

    <jxb:bindings 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
        version="2.1">
        <jxb:bindings schemaLocation="schema.xsd">
            <jxb:bindings node="//xs:simpleType[@name='error']/xs:restriction/xs:enumeration[@value='1']">
                <jxb:typesafeEnumMember name="ONE"/>
            </jxb:bindings>
            <jxb:bindings node="//xs:simpleType[@name='error']/xs:restriction/xs:enumeration[@value='2']">
                <jxb:typesafeEnumMember name="TWO"/>
            </jxb:bindings>
        </jxb:bindings>
    </jxb:bindings>
    

    Full Example

    • Enums don't match schema: problem with jaxb or xsd?

    UPDATE

    Then what is the point of adding following annotation –
    @XmlEnumValue(“1”)

    In your start from Java classes use case you used the @XmlEnumValue("1") annotation to map your enum to the desired XML structure.

      <xs:simpleType name="error">
        <xs:restriction base="xs:int">
          <xs:enumeration value="1"/>
          <xs:enumeration value="2"/>
        </xs:restriction>
      </xs:simpleType>
    

    JAXB implementations don’t generate JAXB information into the XML schema, so if someone wants to generate a Java model from the generated schema then a binding file can be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The first one is enum class enum coffeeSize{ BIG(8), HUGE(10), OVERWHELMING(16); private int ounces;
I want to mplement function that returns enum: class myClass{ private: res _res; public:
I've a enum class like, public enum USERTYPE { Permanant=1, Temporary=2, } in my
I'm using std::error_code and have a bunch of error's defined (using enum class) and
Given a class containing an enum: public class MyClass { public enum NestedEnum {
I have the following class: class Enum(RootFragment): def __init__(self, column, packageName, name, modifiers=[public], enumValues=[]):
I have an enum class like this: public enum Position { A1(0,0), A2(1,0), //etc
I have an enum class like the following: public enum Letter { OMEGA_LETTER(Omega), GAMMA_LETTER(Gamma),
class A { public: enum class { HELLO, WORLD }; }; Having known that,
I have enum class public enum CommandEnum { ADD_ITEM { { this.command = new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.