wood burning stoves*
The moose likes XML and Related Technologies and the fly likes JAXB schemagen output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB schemagen output " Watch "JAXB schemagen output " New topic
Author

JAXB schemagen output

Ong Vua
Ranch Hand

Joined: Jan 24, 2008
Posts: 59
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

Joined: Oct 08, 2010
Posts: 131

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

Joined: Jan 24, 2008
Posts: 59
Sorry, the field is lastname. I don't see it.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXB schemagen output
 
Similar Threads
Parsing XML agaist XSD using - (Want to remove the physical path of xsd from xml)
JAXB Saving and loading a generic List of type T to/from XML
how to validate soap with xsd
From .Net DataTable to Java which object?
problem with schema program