Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

(JAXB) XJC compiles schema but output does not compile. (Recursion)

800281Dec 10 2009 — edited Aug 22 2011
Hello,

I am new to JAXB but decided to give it a try.
I have a nested schema like this:
...
  <xs:element name="topic">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="topic" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="topic" minOccurs="1" maxOccurs="1">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="topic" minOccurs="0" maxOccurs="unbounded">
...
And when xjc compiled I get Java code which don't compile.

Example in Topic.java
public class Topic {
    ...
   public static class Topic {
       ...
    }
}
with the error "+The nested type Topic cannot hide an enclosing type+"

The problem is obviously that xjc creates nested classes with the same name as the parent class.
The XML Schema works fine in reqular XML editors.
Is it so that xjc only works with tailored schemas and I must read up on its limitation or is xjc intended to work with all valid schemas?
In either case do someone have any tips or thoughts on this.


/Thanks Farmor
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 19 2011
Added on Dec 10 2009
3 comments
3,378 views