First time poster, short time lurker. The castor rocks! I hope I don't
insult you with my problem. I've really tried to do my due diligence before
posting. I've searched through the archives trying to find a solution to
this problem. I see some similar, but nothing for my scenario. I downloaded
and build the latest snapshot out of CVS as of tonight, and had the same
issue. My scenario is the following:
I have a rather complicated schema that has has a bunch of complextype's
with nested sequeunces of choices. I'm not using any mapping files or doing
anything other than what is provided in a default castor configuration to
generate the java code. The code generates successfully, however when trying
to unmarshall a valid instance document to java, I get an exception. It
appears as if the generated code is only able to contain one element, and
did not generate code to contain a collection of elements. Is a mapping file
the solution here? Below are three items:
1) the exception
2) a snippet of the xsd <- hand obfuscated to protect the innocent
3) the castor generated code <- hand obfuscated to protect the innocent
========
ValidationException: element "FIELDS" occurs more than once.
(XMLFieldDesciptor: _FIELDS AS FIELDS)
at org.exolab.castor.xml.UnmarshalHandler.endElement(Unknown Source)
at org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator
.java:1550)
at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1809)
at
og.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XML
DocumentScanner.java:1182)
at
rg.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.j
ava:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unknown Source)
at foo.castor.WFML.unmarshal(WFML.java:545)
at foo.harness.ATCGLoader.main(ATCGLoader.java:70)
==========
<xsd:element name="oneof">
<xsd:complextype>
<xsd:sequence>
<xsd:choice minoccurs="0" maxoccurs="unbounded">
<xsd:element ref="test1" />
<xsd:element ref="bogus" />
<xsd:element ref="foo" />
<xsd:element ref="fields" />
<xsd:element ref="fudge" />
<xsd:element ref="rockandroll" />
<xsd:element ref="javatime" />
<xsd:element ref="coldbeer" />
<xsd:element ref="homersimpson" />
<xsd:element ref="donughts" />
<xsd:element ref="confirmed" />
<xsd:element ref="diary" />
<xsd:element ref="invoke" />
<xsd:element ref="code" />
</xsd:choice>
</xsd:sequence>
</xsd:complextype>
</xsd:element>
============
/*
* This class was automatically generated with
* <a href="http://castor.exolab.org">Castor 0.9.4</a>, using an
* XML Schema.
* $Id$
*/
package foo.castor;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.*;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;
/**
*
*
* @version $Revision$ $Date$
**/
public class TEST1 implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
private TEST1 _TEST1;
private BOGUS _BOGUS;
private FOO _FOO;
private FIELDS _FIELDS;
private FUDGE _FUDGE;
private ROCKANDROLL _ROCKANDROLL;
private JAVATIME _JAVATIME;
private COLDBEER _COLDBEER;
private HOMERSIMPSON _HOMERSIMPSON;
private DONUGHTS _DONUGHTS;
private CONFIRMED _CONFIRMED;
private DIARY _DIARY;
private INVOKE _INVOKE;
private java.lang.String _CODE;
//----------------/
//- Constructors -/
//----------------/
public TEST1() {
super();
} //-- foo.castor.TEST1()
//-----------/
//- Methods -/
//-----------/
/**
* Returns the value of field 'FOO'.
*
* @return the value of field 'FOO'.
**/
public FOO getFOO()
{
return this._FOO;
} //-- FOO getFOO()
/**
* Returns the value of field 'BOGUS'.
*
* @return the value of field 'BOGUS'.
**/
public BOGUS getBOGUS()
{
return this._BOGUS;
} //-- BOGUS getBOGUS()
/**
* Returns the value of field 'CODE'.
*
* @return the value of field 'CODE'.
**/
public java.lang.String getCODE()
{
return this._CODE;
} //-- java.lang.String getCODE()
/**
* Returns the value of field 'CONFIRMED'.
*
* @return the value of field 'CONFIRMED'.
**/
public CONFIRMED getCONFIRMED()
{
return this._CONFIRMED;
} //-- CONFIRMED getCONFIRMED()
/**
* Returns the value of field 'DIARY'.
*
* @return the value of field 'DIARY'.
**/
public DIARY getDIARY()
{
return this._DIARY;
} //-- DIARY getDIARY()
/**
* Returns the value of field 'DONUGHTS'.
*
* @return the value of field 'DONUGHTS'.
**/
public DONUGHTS getDONUGHTS()
{
return this._DONUGHTS;
} //-- DONUGHTS getDONUGHTS()
/**
* Returns the value of field 'FIELDS'.
*
* @return the value of field 'FIELDS'.
**/
public FIELDS getFIELDS()
{
return this._FIELDS;
} //-- FIELDS getFIELDS()
/**
* Returns the value of field 'ROCKANDROLL'.
*
* @return the value of field 'ROCKANDROLL'.
**/
public ROCKANDROLL getROCKANDROLL()
{
return this._ROCKANDROLL;
} //-- ROCKANDROLL getROCKANDROLL()
/**
* Returns the value of field 'INVOKE'.
*
* @return the value of field 'INVOKE'.
**/
public INVOKE getINVOKE()
{
return this._INVOKE;
} //-- INVOKE getINVOKE()
/**
* Returns the value of field 'FUDGE'.
*
* @return the value of field 'FUDGE'.
**/
public FUDGE getFUDGE()
{
return this._FUDGE;
} //-- FUDGE getFUDGE()
/**
* Returns the value of field 'TEST1'.
*
* @return the value of field 'TEST1'.
**/
public TEST1 getTEST1()
{
return this._TEST1;
} //-- TEST1 getTEST1()
/**
* Returns the value of field 'COLDBEER'.
*
* @return the value of field 'COLDBEER'.
**/
public COLDBEER getCOLDBEER()
{
return this._COLDBEER;
} //-- COLDBEER getCOLDBEER()
/**
* Returns the value of field 'HOMERSIMPSON'.
*
* @return the value of field 'HOMERSIMPSON'.
**/
public HOMERSIMPSON getHOMERSIMPSON()
{
return this._HOMERSIMPSON;
} //-- HOMERSIMPSON getHOMERSIMPSON()
/**
* Returns the value of field 'JAVATIME'.
*
* @return the value of field 'JAVATIME'.
**/
public JAVATIME getJAVATIME()
{
return this._JAVATIME;
} //-- JAVATIME getJAVATIME()
/**
**/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid()
/**
*
*
* @param out
**/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer)
/**
*
*
* @param handler
**/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler)
/**
* Sets the value of field 'ALLOF'.
*
* @param ALLOF the value of field 'ALLOF'.
**/
public void setALLOF(ALLOF ALLOF)
{
this._ALLOF = ALLOF;
} //-- void setALLOF(ALLOF)
/**
* Sets the value of field 'ANYOF'.
*
* @param ANYOF the value of field 'ANYOF'.
**/
public void setANYOF(ANYOF ANYOF)
{
this._ANYOF = ANYOF;
} //-- void setANYOF(ANYOF)
/**
* Sets the value of field 'CODE'.
*
* @param CODE the value of field 'CODE'.
**/
public void setCODE(java.lang.String CODE)
{
this._CODE = CODE;
} //-- void setCODE(java.lang.String)
/**
* Sets the value of field 'CONFIRMED'.
*
* @param CONFIRMED the value of field 'CONFIRMED'.
**/
public void setCONFIRMED(CONFIRMED CONFIRMED)
{
this._CONFIRMED = CONFIRMED;
} //-- void setCONFIRMED(CONFIRMED)
/**
* Sets the value of field 'DIARY'.
*
* @param DIARY the value of field 'DIARY'.
**/
public void setDIARY(DIARY DIARY)
{
this._DIARY = DIARY;
} //-- void setDIARY(DIARY)
/**
* Sets the value of field 'EVENTOCCURRED'.
*
* @param EVENTOCCURRED the value of field 'EVENTOCCURRED'.
**/
public void setEVENTOCCURRED(EVENTOCCURRED EVENTOCCURRED)
{
this._EVENTOCCURRED = EVENTOCCURRED;
} //-- void setEVENTOCCURRED(EVENTOCCURRED)
/**
* Sets the value of field 'FIELDS'.
*
* @param FIELDS the value of field 'FIELDS'.
**/
public void setFIELDS(FIELDS FIELDS)
{
this._FIELDS = FIELDS;
} //-- void setFIELDS(FIELDS)
/**
* Sets the value of field 'GLOBALS'.
*
* @param GLOBALS the value of field 'GLOBALS'.
**/
public void setGLOBALS(GLOBALS GLOBALS)
{
this._GLOBALS = GLOBALS;
} //-- void setGLOBALS(GLOBALS)
/**
* Sets the value of field 'INVOKE'.
*
* @param INVOKE the value of field 'INVOKE'.
**/
public void setINVOKE(INVOKE INVOKE)
{
this._INVOKE = INVOKE;
} //-- void setINVOKE(INVOKE)
/**
* Sets the value of field 'LOCALS'.
*
* @param LOCALS the value of field 'LOCALS'.
**/
public void setLOCALS(LOCALS LOCALS)
{
this._LOCALS = LOCALS;
} //-- void setLOCALS(LOCALS)
/**
* Sets the value of field 'ONEOF'.
*
* @param ONEOF the value of field 'ONEOF'.
**/
public void setONEOF(ONEOF ONEOF)
{
this._ONEOF = ONEOF;
} //-- void setONEOF(ONEOF)
/**
* Sets the value of field 'SERVICECONFIG'.
*
* @param SERVICECONFIG the value of field 'SERVICECONFIG'.
**/
public void setSERVICECONFIG(SERVICECONFIG SERVICECONFIG)
{
this._SERVICECONFIG = SERVICECONFIG;
} //-- void setSERVICECONFIG(SERVICECONFIG)
/**
* Sets the value of field 'SUBSCRIBERPREF'.
*
* @param SUBSCRIBERPREF the value of field 'SUBSCRIBERPREF'.
**/
public void setSUBSCRIBERPREF(SUBSCRIBERPREF SUBSCRIBERPREF)
{
this._SUBSCRIBERPREF = SUBSCRIBERPREF;
} //-- void setSUBSCRIBERPREF(SUBSCRIBERPREF)
/**
* Sets the value of field 'SYSTEMCONFIG'.
*
* @param SYSTEMCONFIG the value of field 'SYSTEMCONFIG'.
**/
public void setSYSTEMCONFIG(SYSTEMCONFIG SYSTEMCONFIG)
{
this._SYSTEMCONFIG = SYSTEMCONFIG;
} //-- void setSYSTEMCONFIG(SYSTEMCONFIG)
/**
*
*
* @param reader
**/
public static foo.castor.ONEOF unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
{
return (atcg.castor.ONEOF)
Unmarshaller.unmarshal(atcg.castor.ONEOF.class, reader);
} //-- atcg.castor.ONEOF unmarshal(java.io.Reader)
/**
**/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new
org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate()
}
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev