chenwei
asked on
A question about XML enum to java enum
My XSD-schema looks as follow:
[code]
...
<!-- Person -->
<xs:complexType name="Person">
<xs:sequence>
...
<xs:element name="titel" type="tns:Titel" minOccurs="0" />
...
</xs:sequence>
</xs:complexType>
...
<!-- Titel -->
<xs:simpleType name="Titel">
<xs:restriction base="xs:string">
<xs:enumeration value="" />
<xs:enumeration value="Dr." />
<xs:enumeration value="Dr.Dr." />
<xs:enumeration value="Prof." />
<xs:enumeration value="Prof.Dr." />
</xs:restriction>
</xs:simpleType>
[/code]
But as I complie the XSD-Schema to java.enum, it failed. I don't know what's wrong.
[code]
...
<!-- Person -->
<xs:complexType name="Person">
<xs:sequence>
...
<xs:element name="titel" type="tns:Titel" minOccurs="0" />
...
</xs:sequence>
</xs:complexType>
...
<!-- Titel -->
<xs:simpleType name="Titel">
<xs:restriction base="xs:string">
<xs:enumeration value="" />
<xs:enumeration value="Dr." />
<xs:enumeration value="Dr.Dr." />
<xs:enumeration value="Prof." />
<xs:enumeration value="Prof.Dr." />
</xs:restriction>
</xs:simpleType>
[/code]
But as I complie the XSD-Schema to java.enum, it failed. I don't know what's wrong.
Which compiler are you using?
What is your target version of Java?
Your original Version of code works fine using Apache XMLBeans. However, if your xsd compiler was actually trying to map enumerations to Java 5 Enums, then you can't have periods in the names. as that would break the Java 5 naming conventions for type/class names.
What is your target version of Java?
Your original Version of code works fine using Apache XMLBeans. However, if your xsd compiler was actually trying to map enumerations to Java 5 Enums, then you can't have periods in the names. as that would break the Java 5 naming conventions for type/class names.
ASKER
I use the Jaxb and the target is Java 5. Maybe this is the problem?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's quite stranged. I run my program at home's computer and it works. ut when I run the program at office's computer it failed.
Anyway many thanks.
Anyway many thanks.
ASKER
<!-- Titel -->
<xs:simpleType name="Titel">
<xs:restriction base="xs:string">
<xs:enumeration value="" />
<xs:enumeration value="Dr" />
<xs:enumeration value="DrDr" />
<xs:enumeration value="Prof" />
<xs:enumeration value="ProfDr" />
</xs:restriction>
</xs:simpleType>