Solved

A question about XML enum to java enum

Posted on 2008-09-29
5
1,187 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
  • 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 50 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now