Solved

A question about XML enum to java enum

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

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