4 Replies Latest reply: May 10, 2012 11:34 AM by user8742475 RSS

    JAXB schemagen output

    user8742475
      I have 2 simple classes as below and after I run schemagen.bat, I got the below output. I don't see lastname field but instead key and value elements. Should it have lastname element?

      Thanks

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <xs:complexType name="class1">
      <xs:sequence>
      <xs:element name="class2">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="key" minOccurs="0" type="xs:anyType"/>
      <xs:element name="value" minOccurs="0" type="xs:anyType"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      <xs:element name="firstname" type="xs:string" minOccurs="0"/>
      </xs:sequence>
      </xs:complexType>
      </xs:schema>


      package project1;

      public class Class1 {

      String firstname;
      Class2 class2;

      public void setClass2(Class2 class2) {
      this.class2 = class2;
      }

      public Class2 getClass2() {
      return class2;
      }

      public void setFirstname(String firstname) {
      this.firstname = firstname;
      }

      public String getFirstname() {
      return firstname;
      }
      }

      package project1;

      public class Class2 {

      String lastname;

      public Class2() {
      System.out.println("Inside Class 2");
      }


      public void setLastname(String lastname) {
      this.lastname = lastname;
      }

      public String getLastname() {
      return lastname;
      }
      }
        • 1. Re: JAXB schemagen output
          tsuji
          What schemagen.bat is it? What is its origin, version/package?
          • 2. Re: JAXB schemagen output
            user8742475
            I downloaded the latest JAXB package, JAXB2_20120218.jar from http://jaxb.java.net/2.2.5/
            • 3. Re: JAXB schemagen output
              tsuji
              I have been using RI 2.2.1. I specifically download RI 2.2.5. But one version or the other, I cannot reproduce what you list up there. What I see looks much sound, and I invent nothing special, just bare minimal inputs to it.
              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
              
                <xs:complexType name="class1">
                  <xs:sequence>
                    <xs:element name="class2" type="class2" minOccurs="0"/>
                    <xs:element name="firstname" type="xs:string" minOccurs="0"/>
                  </xs:sequence>
                </xs:complexType>
              
                <xs:complexType name="class2">
                  <xs:sequence>
                    <xs:element name="lastname" type="xs:string" minOccurs="0"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:schema>
              • 4. Re: JAXB schemagen output
                user8742475
                It's user error :) I only supply Class1.java and not Class2.java

                Thanks