Solved

A question about XML enum to java enum

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 37
Convert from a json string array to a Java object 3 65
learn programming 8 72
passing enum to a method 4 36
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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