Skip to main content

JAXB schemagen output

1 reply [Last post]
hoangtu69
Offline
Joined: 2011-12-18
Points: 0

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;
    }
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
_DD
Offline
Joined: 2012-03-27
Points: 0

Read & use annotations in your classes, that will help. Schemagen is giving you a generic layout here.