problem with jaxb

Hi! I have this xml:

<?xml version="1.0"?>

<qcoheader>

<types>

<type id="1">CORE</type>

<type id="13">ECTZ</type>

</types>

<disLevels>

<level id="1">Normale</level>

</disLevels>

<versions>

<version id="1">4-0</version>

<version id="4">1-0ED</version>

</versions>

<languages>

<language id="1">IT</language>

<language id="2">EN</language>

<language id="3">ES</language>

</languages>

<swSuites>

<suite id="2">2K</suite>

<suite id="3">XP</suite>

<suite id="4">IEOE</suite>

</swSuites>

<formats>

<format id="2" name="simulation" subtype="multians">Simulazione</format>

<format id="3" name="nonperformance" subtype="simple">MCQ</format>

</formats>

<modules>

<module id="1000">- ECDL -</module>

<module id="1">ECDL - Mod 1</module>

<module id="2">ECDL - Mod 2</module>

<module id="3">ECDL - Mod 3</module>

<module id="4">ECDL - Mod 4</module>

<module id="5">ECDL - Mod 5</module>

<module id="6">ECDL - Mod 6</module>

</modules>

</qcoheader>

and this xsd:

--

<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

<xsd:element name="qcoheader">

<xsd:complexType>

<xsd:sequence>

<xsd:element ref="types"/>

<xsd:element ref="disLevels"/>

<xsd:element ref="versions"/>

<xsd:element ref="languages"/>

<xsd:element ref="swSuites"/>

<xsd:element ref="formats"/>

<xsd:element ref="modules"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="types">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" ref="type"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="type">

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:NCName">

<xsd:attribute name="id" use="required" type="xsd:integer"/>

</xsd:extension>

</xsd:simpleContent>

</xsd:complexType>

</xsd:element>

<xsd:element name="disLevels">

<xsd:complexType>

<xsd:sequence>

<xsd:element ref="level"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="level">

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:NCName">

<xsd:attribute name="id" use="required" type="xsd:integer"/>

</xsd:extension>

</xsd:simpleContent>

</xsd:complexType>

</xsd:element>

<xsd:element name="versions">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" ref="version"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="version">

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:NMTOKEN">

<xsd:attribute name="id" use="required" type="xsd:NMTOKEN"/>

</xsd:extension>

</xsd:simpleContent>

</xsd:complexType>

</xsd:element>

<xsd:element name="languages">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" ref="language"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="language">

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:NCName">

<xsd:attribute name="id" use="required" type="xsd:integer"/>

</xsd:extension>

</xsd:simpleContent>

</xsd:complexType>

</xsd:element>

<xsd:element name="swSuites">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" ref="suite"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="suite">

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:NMTOKEN">

<xsd:attribute name="id" use="required" type="xsd:NMTOKEN"/>

</xsd:extension>

</xsd:simpleContent>

</xsd:complexType>

</xsd:element>

<xsd:element name="formats">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" ref="format"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="format">

<xsd:complexType>

<xsd:simpleContent>

<xsd:extension base="xsd:NCName">

<xsd:attribute name="id" use="required" type="xsd:integer"/>

<xsd:attribute name="name" use="required" type="xsd:NCName"/>

<xsd:attribute name="subtype" use="required" type="xsd:NCName"/>

</xsd:extension>

</xsd:simpleContent>

</xsd:complexType>

</xsd:element>

<xsd:element name="modules">

<xsd:complexType>

<xsd:sequence>

<xsd:element maxOccurs="unbounded" ref="module"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:element name="module">

<xsd:complexType mixed="true">

<xsd:attribute name="id" use="required" type="xsd:NMTOKEN"/>

</xsd:complexType>

</xsd:element>

</xsd:schema>

I used autogeneration of JAXB classes in package qcodetails but when I try to read the xml it gives me this error:

[java] Exception in thread "main" java.lang.ClassCastException: qcodetails.Qcoheader

Does anyone know the reason? Maybe xsd file is wrong?

Thanks,

fabio

[6654 byte] By [meoa] at [2007-10-3 3:48:29]
# 1

Exception in thread "main" java.lang.NoClassDefFound

The reason people get this is because an error has happened at the time you run the program.

there is only one reason why you get this the class you are trying to get to is not in the classpath.

reasons why it might not be in the classpath:

1- misspeled command when executing the command to run

(command doesn't match the .class filename)

2- classpath doesn't include your class location, jar locations or any other place the code might be in

here is a link on how to set the classpath when running the command

to run your class

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html

when using jaxb you have to precompile the schemas a head of time.

and the location of those classes must be in the classpath

discussjava.com_a at 2007-7-14 21:45:31 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...