Werner,

I have attached the source code file.

Stefan

 --- Werner Guttmann <[EMAIL PROTECTED]>
schrieb: 
> Stefan,
> 
> Can you please post the source code for the
> (generated)
> StateStateMomentType class ? It looks odd to me that
> any class generated
> by the source generator would not have a default
> constructor. Having
> said that, as you are specifing an enum, this migth
> as well be the case
> ... ;-). Let's look at the class first.
> 
> Regards
> Werner
> 
> > -----Original Message-----
> > From: Stefan Lober [mailto:[EMAIL PROTECTED] 
> > Sent: Dienstag, 22. November 2005 17:14
> > To: [email protected]
> > Subject: [castor-user] [XML/JDO] Problems using 
> > ClassDescriptors and a mapping file
> > 
> > Hello,
> > I have built my project around Castor using an XML
> Schema as 
> > starting point for my development.
> > The development process is planned to be as
> follows:
> > XSD => Java source (via SourceGenerator) Java
> source => Java 
> > classes (Java compiler) Java classes => mapping
> file for 
> > XML&JDO (MappingTool)
> > 
> > I have modified the MappingTool class, so that it
> also 
> > integrates JDO mapping information in my mapping
> file.
> > The intention is to unmarshal an XML document
> (described by 
> > the XSD) and persist it in the database.
> > 
> > Unfortunately, a construct in the XSD causes some
> problems. 
> > This is it:
> > 
> > <element name="state">
> >  <complexType mixed="true">
> >   <attribute name="id" type="int" use="optional"
> />
> >   <attribute name="state-moment" use="required">
> >    <simpleType>
> >     <restriction base="NMTOKEN">
> >      <enumeration value="Unknown" />
> >      <enumeration value="StateEnd" />
> >      <enumeration value="StateBegin" />
> >     </restriction>
> >    </simpleType>
> >   </attribute>
> >   <attribute name="stamptime" type="string"
> > use="required" />
> >  </complexType>
> > </element>
> > 
> > This element is referenced from a another element
> in the schema.
> > 
> > First, I had let the SourceGenerator generate ONLY
> the 
> > classes and NO class descriptors (with
> -gen-mapping and -nodesc).
> > I get this mapping back from MappingTool:
> > 
> > <class cst:name="log.State"
> > cst:depends="log.Systemstates" cst:identity="id"
> > cst:key-generator="MAX">
> >   <description>Default mapping for class
> log.State</description>
> >   <map-to cst:table="State" cst:xml="state" />
> <field 
> > cst:name="valid" cst:type="boolean">
> >   <sql name="valid" dirty="check" />
> >   <bind-xml name="valid" node="attribute" />
> >   </field>
> > <field cst:name="id" cst:type="integer">
> >   <sql name="id" type="integer" dirty="check" />
> >   <bind-xml name="id" node="attribute" />
> >   </field>
> > <field cst:name="content" cst:type="string">
> >   <sql name="content" type="char" dirty="check" />
> >   <bind-xml name="content" node="element" />
> >   </field>
> > <field cst:name="stamptime" cst:type="string">
> >   <sql name="stamptime" type="char" dirty="check"
> />
> >   <bind-xml name="stamptime" node="element" />
> >   </field>
> > </class>
> > 
> > This gives me the following error when the
> unmarshal method is called:
> > 
> > Illegal Text data found as child of: state
> >   value: "INIT"{file: [not available]; line: 5;
> > column: 85}
> >     at
> >
>
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:671)
> > 
> > The according XML line ist this:
> > 
> > <state state-moment="StateBegin"
> > stamptime="2005-10-25T11:46:09" >INIT</state>
> > 
> > ---------------------------------
> > 
> > So I tried using the class descriptors.
> Unmarshalling the XML 
> > document works now. But as soon as I try to
> persist the data 
> > in the DB, I have to use the generated mapping
> (form 
> > MappingTool). The call of
> JDOManager.loadConfiguration 
> > results in the following
> > exception:
> > 
> > org.exolab.castor.mapping.MappingException: The
> Java class 
> > log.types.StateStateMomentType is not
> constructable -- it 
> > does not contain a default public constructor
> >     at
> >
>
org.exolab.castor.mapping.loader.ClassDescriptorImpl.<init>(Cl
> > assDescriptorImpl.java:161)
> > 
> > Is my approach of using class descriptors AND a
> mapping file 
> > the reason for this problem?
> > Is it possible to solve this?
> > 
> > Another question: Is it possible to use a 
> > GerealizedFieldHandler WITHOUT a mapping file?
> > 
> > Any hint would be appreciated.
> > 
> > Stefan
> > 
> > 
> >     
> > 
> >     
> >             
> >
>
___________________________________________________________
> > Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher
> kostenlos - 
> > Hier anmelden: http://mail.yahoo.de
> > 
> > -------------------------------------------------
> > If you wish to unsubscribe from this list, please
> send an 
> > empty message to the following address:
> > 
> > [EMAIL PROTECTED]
> > -------------------------------------------------
> > 
> > 
> > 
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------
> 
>  



        

        
                
___________________________________________________________ 
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: 
http://mail.yahoo.de
/* * This class was automatically generated with * Castor 0.9.9, using an XML * Schema. * $Id$ */ package log.types; //---------------------------------/ //- Imported classes and packages -/ //---------------------------------/ import java.io.Serializable; import java.util.Enumeration; import java.util.Hashtable; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** * Class StateStateMomentType. * * @version $Revision$ $Date$ */ public class StateStateMomentType implements java.io.Serializable { //--------------------------/ //- Class/Member Variables -/ //--------------------------/ /** * The Unknown type */ public static final int UNKNOWN_TYPE = 0; /** * The instance of the Unknown type */ public static final StateStateMomentType UNKNOWN = new StateStateMomentType(UNKNOWN_TYPE, "Unknown"); /** * The StateEnd type */ public static final int STATEEND_TYPE = 1; /** * The instance of the StateEnd type */ public static final StateStateMomentType STATEEND = new StateStateMomentType(STATEEND_TYPE, "StateEnd"); /** * The StateBegin type */ public static final int STATEBEGIN_TYPE = 2; /** * The instance of the StateBegin type */ public static final StateStateMomentType STATEBEGIN = new StateStateMomentType(STATEBEGIN_TYPE, "StateBegin"); /** * Field _memberTable */ private static java.util.Hashtable _memberTable = init(); /** * Field type */ private int type = -1; /** * Field stringValue */ private java.lang.String stringValue = null; //----------------/ //- Constructors -/ //----------------/ private StateStateMomentType(int type, java.lang.String value) { super(); this.type = type; this.stringValue = value; } //-- log.types.StateStateMomentType(int, java.lang.String) //-----------/ //- Methods -/ //-----------/ /** * Method enumerate * * Returns an enumeration of all possible instances of * StateStateMomentType * * @return Enumeration */ public static java.util.Enumeration enumerate() { return _memberTable.elements(); } //-- java.util.Enumeration enumerate() /** * Method getType * * Returns the type of this StateStateMomentType * * @return int */ public int getType() { return this.type; } //-- int getType() /** * Method init * * * * @return Hashtable */ private static java.util.Hashtable init() { Hashtable members = new Hashtable(); members.put("Unknown", UNKNOWN); members.put("StateEnd", STATEEND); members.put("StateBegin", STATEBEGIN); return members; } //-- java.util.Hashtable init() /** * Method readResolve * * will be called during deserialization to replace the * deserialized object with the correct constant instance. *
* * @return Object */ private java.lang.Object readResolve() { return valueOf(this.stringValue); } //-- java.lang.Object readResolve() /** * Method toString * * Returns the String representation of this * StateStateMomentType * * @return String */ public java.lang.String toString() { return this.stringValue; } //-- java.lang.String toString() /** * Method valueOf * * Returns a new StateStateMomentType based on the given String * value. * * @param string * @return StateStateMomentType */ public static log.types.StateStateMomentType valueOf(java.lang.String string) { java.lang.Object obj = null; if (string != null) obj = _memberTable.get(string); if (obj == null) { String err = "'" + string + "' is not a valid StateStateMomentType"; throw new IllegalArgumentException(err); } return (StateStateMomentType) obj; } //-- log.types.StateStateMomentType valueOf(java.lang.String) }
-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to