У меня много трудностей с созданием некоторых POJO из XSD (распространяемых как стандарт, который у меня отсутствует, и я не могу изменить) с помощью JAXB. Проблема, похоже, связана с тем, как определенные типы определены в этом XSD. Ниже я вставил простой тип, определенный в этом XSD с именем TransactionCodeType, который является объединением маркера в сочетании с списком перечислений значений, также определяемым как токен.Невозможно создать класс перечисления с использованием JAXB
<xs:element name="TransactionContentDetails">
<xs:complexType>
<xs:sequence>
<xs:element name="TransactionIdentifier" type="xs:string" minOccurs="0"/>
<xs:element name="TransactionCode" type="TransactionCodeType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="TransactionCodeType">
<xs:union memberTypes="xs:token">
<xs:simpleType>
<xs:restriction base="xs:token">
xs:enumeration value="Design E-Filing"/>
<xs:enumeration value="Design B2B-Filing" />
<xs:enumeration value="Design Information" />
<xs:enumeration value="Design Identifier List" />
<xs:enumeration value="Design List" />
<xs:enumeration value="Design Opposition E-Filing" />
<xs:enumeration value="Design Opposition Information" />
<xs:enumeration value="Design Opposition Identifier List" />
<xs:enumeration value="Representative Appointment" />
<xs:enumeration value="Amendment Registered Design" />
<xs:enumeration value="Amendment Application" />
<xs:enumeration value="Convention Application" />
<xs:enumeration value="Additional Application" />
<xs:enumeration value="Subsequent Application" />
<xs:enumeration value="Divisional Application" />
<xs:enumeration value="Assignment Application" />
<xs:enumeration value="Assignment Registered Design" />
<xs:enumeration value="Request Certified Copies" />
<xs:enumeration value="Request Extension Time" />
<xs:enumeration value="Request Hearing" />
<xs:enumeration value="Opposition First Extension" />
<xs:enumeration value="Opposition Various Renewal/Extension of Registration Restoration" />
<xs:enumeration value="Withdrawal" />
<xs:enumeration value="Withdraw Application" />
<xs:enumeration value="Withdraw Design" />
<xs:enumeration value="Response Examination Report" />
<xs:enumeration value="Statement Support" />
<xs:enumeration value="Withdraw Service Request" />
<xs:enumeration value="Request Publication" />
<xs:enumeration value="Request Registration" />
<xs:enumeration value="Offer Surrender" />
<xs:enumeration value="Request Exclusion" />
<xs:enumeration value="Request Conversion" />
<xs:enumeration value="Duplicate Certificate" />
<xs:enumeration value="Request Supply Documents" />
<xs:enumeration value="Request Delayed Registration" />
<xs:enumeration value="Request Accelerated Examination" />
<xs:enumeration value="Expiry Notice" />
<xs:enumeration value="Refusal Withdrawal Notification" />
<xs:enumeration value="Division International Registration Notification" />
<xs:enumeration value="Refusal Notification" />
<xs:enumeration value="Providing Certificate To Holder" />
<xs:enumeration value="Transmittal Application To IB" />
<xs:enumeration value="Irregularities" />
<xs:enumeration value="Invalidation Notification" />
<xs:enumeration value="Cancellation Representative Appointment" />
<xs:enumeration value="Application Receipt" />
<xs:enumeration value="Notice Document By Design Formality Examination" />
<xs:enumeration value="Notice Document By Design Substantial Examination" />
<xs:enumeration value="Notice Document By Design Registration" />
<xs:enumeration value="Notice Document By Trial Examination - Invitation" />
<xs:enumeration value="Notice Document By Trial Examination" />
<xs:enumeration value="Notice Document By Trial Examination - Decision" />
<xs:enumeration value="Memo By Design Formality Examination" />
<xs:enumeration value="Memo By Design Substantial Examination" />
<xs:enumeration value="Memo By Trial Examination" />
<xs:enumeration value="Memo By Trial Notice" />
<xs:enumeration value="Memo By Trial Examination - Correction" />
<xs:enumeration value="Accept Design Application Document" />
<xs:enumeration value="Accept Design Applicant Document" />
<xs:enumeration value="Accept Design Attorney Document" />
<xs:enumeration value="Accept Design Withdrawal And Abandonment Document" />
<xs:enumeration value="Accept Design Response Document" />
<xs:enumeration value="Accept Design Submission Document" />
<xs:enumeration value="Accept Design Amendment Document" />
<xs:enumeration value="Accept Design Request For Inspection" />
<xs:enumeration value="Accept Demand For A Trial" />
<xs:enumeration value="Accept Trial Intermediate Document" />
<xs:enumeration value="Inspection Accept Design Application Document" />
<xs:enumeration value="Inspection Accept Design Applicant Document" />
<xs:enumeration value="Inspection Accept Design Attorney Document" />
<xs:enumeration value="Inspection Accept Design Withdrawal And Abandonment Document" />
<xs:enumeration value="Inspection Accept Design Response Document" />
<xs:enumeration value="Inspection Accept Design Submission Document" />
<xs:enumeration value="Inspection Accept Design Amendment Document" />
<xs:enumeration value="Inspection Accept Design Request For Inspection" />
<xs:enumeration value="Inspection Accept Demand For A Trial" />
<xs:enumeration value="Inspection Accept Trial Intermediate Document" />
<xs:enumeration value="Inspection Notice Document By Design Formality Examination" />
<xs:enumeration value="Inspection Notice Document By Design Substantial Examination" />
<xs:enumeration value="Inspection Notice Document By Design Registration" />
<xs:enumeration value="Inspection Notice Document By Trial Examination - Invitation" />
<xs:enumeration value="Inspection Notice Document By Trial Examination" />
<xs:enumeration value="Inspection Notice Document By Trial Examination - Decision" />
<xs:enumeration value="Inspection Memo By Design Formality Examination" />
<xs:enumeration value="Inspection Memo By Design Substantial Examination" />
<xs:enumeration value="Inspection Memo By Trial Examination" />
<xs:enumeration value="Inspection Memo By Trial Notice" />
<xs:enumeration value="Certified Copy Notice Document By Design Formality Examination" />
<xs:enumeration value="Certified Copy Notice Document By Design Substantial Examination" />
<xs:enumeration value="Certified Copy Notice Document By Design Registration" />
<xs:enumeration value="Certified Copy Notice Document By Trial Examination - Invitation" />
<xs:enumeration value="Certified Copy Notice Document By Trial Examination" />
<xs:enumeration value="Certified Copy Notice Document By Trial Examination - Decision" />
<xs:enumeration value="Accept Document List" />
<xs:enumeration value="Notice Document List" />
<xs:enumeration value="Application Information" />
<xs:enumeration value="Balance Sheet Reference" />
<xs:enumeration value="Division Number List" />
<xs:enumeration value="Record Licence" />
<xs:enumeration value="Record Mortgagee" />
<xs:enumeration value="Terminate Licence" />
<xs:enumeration value="Discharge Mortgagee" />
<xs:enumeration value="Change of Name" />
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
Использование JAXB, полученный результат (см. Ниже) переводится как основной тип String в Java. Я использую последнюю версию maven-jaxb2-plugin из org.jvnet.jaxb2.maven2. В какой-то момент это то, чего я ожидал. Поэтому я хотел бы получить доступ из кода Java к списку возможных значений, которые определены в XSD. Но как ? JAXB не генерирует класс перечисления, который определял все эти значения. Я искал в Интернете, в том числе на этом сайте, чтобы найти решения; попробуйте некоторые из предлагаемых решений, включая использование привязок, без каких-либо успехов.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"transactionIdentifier",
"transactionCode",
})
public static class TransactionContentDetails implements Serializable {
@XmlElement(name = "TransactionIdentifier")
protected String transactionIdentifier;
@XmlElement(name = "TransactionCode", required = true)
protected String transactionCode;
public String getTransactionIdentifier() {
return transactionIdentifier;
}
public void setTransactionIdentifier(String value) {
this.transactionIdentifier = value;
}
public String getTransactionCode() {
return transactionCode;
}
public void setTransactionCode(String value) {
this.transactionCode = value;
}
}
Итак, я смотрю, чтобы увидеть, если у вас есть какие-либо идеи о том, как я мог бы решить эту проблему, то есть, будучи в состоянии генерировать класс перечисления Java, содержащий все эти значения. В рамках решения я не хочу переопределять все эти значения в файле привязки.
Спасибо!
см. мой ответ ниже – fantarama