473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Enums not generated by JAXB

I'm using JAXB to generate classes from an XML schema.
I have two simpleTypes with String restrictions to specific enumeration values as follows:

Expand|Select|Wrap|Line Numbers
  1. <xs:simpleType name="RestDaysHandlingMode">
  2.     <xs:restriction base="xs:string">
  3.         <xs:enumeration value="Forward"></xs:enumeration>
  4.         <xs:enumeration value="ForwardUnlessMonthChange"></xs:enumeration>
  5.         <xs:enumeration value="NoShift"></xs:enumeration>
  6.     </xs:restriction>
  7. </xs:simpleType>
  8.  
  9. <xs:simpleType name="YearMonthMethod">
  10.         <xs:restriction base="xs:string">
  11.             <xs:enumeration value="30_360"></xs:enumeration>
  12.             <xs:enumeration value="Actual_360"></xs:enumeration>
  13.             <xs:enumeration value="Actual_365"></xs:enumeration>
  14.             <xs:enumeration value="Actual_Actual"></xs:enumeration>
  15.         </xs:restriction>
  16. </xs:simpleType>
Although no essencial differences are apparent, the JAXB generates an enum from the first one:

Expand|Select|Wrap|Line Numbers
  1. @XmlEnum
  2. public enum RestDaysHandlingMode {
  3.  
  4.     @XmlEnumValue("Forward")
  5.     FORWARD("Forward"),
  6.     @XmlEnumValue("ForwardUnlessMonthChange")
  7.     FORWARD_UNLESS_MONTH_CHANGE("ForwardUnlessMonthChange"),
  8.     @XmlEnumValue("NoShift")
  9.     NO_SHIFT("NoShift");
  10.     private final String value;
  11.  
  12.     RestDaysHandlingMode(String v) {
  13.         value = v;
  14.     }
  15.  
  16.     public String value() {
  17.         return value;
  18.     }
  19.  
  20.     public static RestDaysHandlingMode fromValue(String v) {
  21.         for (RestDaysHandlingMode c: RestDaysHandlingMode.values()) {
  22.             if (c.value.equals(v)) {
  23.                 return c;
  24.             }
  25.         }
  26.         throw new IllegalArgumentException(v);
  27.     }
  28.  
  29. }

whereas the second type is handled as a simple string (the following is taken from a class that is generated by JAXB and contains an element of the second type):
Expand|Select|Wrap|Line Numbers
  1.     /**
  2.      * Gets the value of the yearMonthMethod property.
  3.      * 
  4.      * @return
  5.      *     possible object is
  6.      *     {@link String }
  7.      *     
  8.      */
  9.     public String getYearMonthMethod() {
  10.         return yearMonthMethod;
  11.     }
  12.  
Any ideas?
Mar 26 '08 #1
2 8728
No help needed, the problem was solved. It's because of this line:
Expand|Select|Wrap|Line Numbers
  1. <xs:enumeration value="30_360"></xs:enumeration>
an identifier that starts with a digit cannot be generated, and so the type is generated as a String.
Mar 27 '08 #2
r035198x
13,262 8TB
No help needed, the problem was solved. It's because of this line:
Expand|Select|Wrap|Line Numbers
  1. <xs:enumeration value="30_360"></xs:enumeration>
an identifier that starts with a digit cannot be generated, and so the type is generated as a String.
Good work. Good luck with the rest of it.
Mar 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jesper | last post by:
Hi I am currently following the tutorial from IBM (http://www-106.ibm.com/developerworks/xml/edu/x-dw-xjaxb-i.html) I have three problems at the moment. 1. It says else where that when the...
0
by: Mark | last post by:
I'm betting it me. Here is the simple schema I'm using: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"...
1
by: Sony Antony | last post by:
We have a situation wherin we should translate the incoming XML based on one schema to the outgoing XML that is based on another schema. Since both input and output are both XML, XSLT was the...
13
by: Christoph Brunner | last post by:
Hi, on the sun homepage i had submit to the bugparade a request for feature enhancement for the JAXB API. After a period of time sun called me to post my request to a newsgroup an get comments...
0
by: Brett Selleck | last post by:
We have an issue where the JAXB generated classes are creating an interface which references itself. The Schema is valid, and I have not seen this ran into before. The code is below. What is...
0
by: Mark | last post by:
I'm betting it me. Here is the simple schema I'm using: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"...
1
by: javatoil260309 | last post by:
Hey guys, I am using an xsd to generate an xml file. For this I'm using jaxb from "https://jaxb.dev.java.net/2.1.9/JAXB2_20081030.jar". I have successfully managed to create marshal for a context...
0
by: kokababu | last post by:
Hi, I have to add xml schema attributes into the java object. Such as, my java object is User. This User object will be represented as XML using JAXB. I generated XML from User object...
1
by: kokababu | last post by:
Hi, I have to add xml schema attributes into the java object. Such as, my java object is User. This User object will be represented as XML using JAXB. I generated XML from User object...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.