?
Solved

A question about XML enum to java enum

Posted on 2008-09-29
5
Medium Priority
?
1,196 Views
Last Modified: 2008-10-01
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.
0
Comment
Question by:chenwei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:chenwei
ID: 22595979
But if I take out the '.' as follow, it is ok. Why?

     <!-- 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>
0
 
LVL 1

Expert Comment

by:MrMarshall
ID: 22599246
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.

0
 

Author Comment

by:chenwei
ID: 22603334
I use the Jaxb and the target is Java 5. Maybe this is the problem?
0
 
LVL 1

Accepted Solution

by:
MrMarshall earned 200 total points
ID: 22617136
What are your JAXB Compile options? What is the failure message?  Yes, that could be the case.
0
 

Author Comment

by:chenwei
ID: 22618131
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question