I\'m trying to use JAXB to unmarshal this file into Java objects. I know that there\'s a problem with SAX in J6 that rejects the maxOccurs line, and I\'ve changed it to
There are a couple of enumeration values that are causing this issue. These issues can be overcome through the use of a JAXB external binding file (see below).
Enum Issue #1 - Empty String
Some of your enum values are empty string (""), which is causing a String rather than an enum property to be generated:
Blank
Enum Issue #2 - Numeric String
Some of the enum values are numbers which is causing a String rather than an enum property to be generated:
6th grade
Bindings File (bindings.xml)
The following bindings file can be used to address the issues with the educationLevelType, the concepts here can be applied to all the problematic types:
The XJC call can be made as follows (the -nv flag is described below):
xjc -nv -b bindings.xml -d out http://www.acf.hhs.gov/programs/cb/systems/nytd/nytd_data_file_format.xsd
This will cause the following Enum to be generated:
package gov.hhs.acf.nytd;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
@XmlType(name = "educationLevelType")
@XmlEnum
public enum EducationLevelType {
@XmlEnumValue("under 6")
UNDER_6("under 6"),
@XmlEnumValue("6")
SIX("6"),
@XmlEnumValue("7")
SEVEN("7"),
@XmlEnumValue("8")
EIGHT("8"),
@XmlEnumValue("9")
NINE("9"),
@XmlEnumValue("10")
TEN("10"),
@XmlEnumValue("11")
ELEVEN("11"),
@XmlEnumValue("12")
TWELVE("12"),
@XmlEnumValue("post secondary")
POST_SECONDARY("post secondary"),
@XmlEnumValue("college")
COLLEGE("college"),
@XmlEnumValue("")
BLANK("");
private final String value;
EducationLevelType(String v) {
value = v;
}
public String value() {
return value;
}
public static EducationLevelType fromValue(String v) {
for (EducationLevelType c: EducationLevelType.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
maxOccurs Issue
For the maxOccurs issue, the following command line with the no verify (-nv) flag can be used to parse the XML schema:
xjc -nv -d out http://www.acf.hhs.gov/programs/cb/systems/nytd/nytd_data_file_format.xsd
This will get you past the following error without having to modify the XML schema:
parsing a schema... [ERROR] Current configuration of the parser doesn't allow a maxOccurs attribute value to be set greater than the value 5,000.
line 41 of http://www.acf.hhs.gov/programs/cb/systems/nytd/nytd_data_file_format.xsdFailed to parse a schema.
For More Information