• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB schemagen output

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
}
 
rohit chavan
Ranch Hand
Posts: 132
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There seems to be a mismatch between the XML you have posted and the corresponding class.
If you look closely , there is no element named
lastName
in the XML file you have put in.

Also, please use
"code"
tag while posting your code.
( 1. chose java/xml from the drop down above ,
2. select your code snippet and
3. click "code" button. )

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, the field is lastname. I don't see it.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic