thank you for your reply.
you are right with your sum up of my problem.
the code is:
// creates XML-document with generated classes
public Dl createJavaXMLDoc () { // creates definition list
Dl defl = new Dl(); // creates and adds definition list item 0 to definition list
defl.addDlItem(new DlItem()); // creates and adds definition term to defintion list item 0
defl.getDlItem(0).setDt(new Dt()); // creates and adds definition term item 0 to definition term
defl.getDlItem(0).getDt().addDtItem(new DtItem()); // creates and adds text to definition term item 0
defl.getDlItem(0).getDt().getDtItem(0).setContentMix_group(
JavaXMLDocHelper.createTxt("test data", false, false, false)); // creates and adds definition list item 1 to definition list
defl.addDlItem(new DlItem()); // creates and adds definition description to defintion list item 1
defl.getDlItem(1).setDd(new Dd());// creates and adds definition description item 0 to definition description
defl.getDlItem(1).getDd().addDdItem(new DdItem());
// creates and adds text to definition description item 0
defl.getDlItem(1).getDd().getDdItem(0).setContentMix_group(
JavaXMLDocHelper.createTxt("test definition", false, false, false));
// creates and adds definition list item 2 to definition list
defl.addDlItem(new DlItem()); // creates and adds definition term to definition list item 2
defl.getDlItem(2).setDt(new Dt()); // creates and adds definition term item 0 to definition term
defl.getDlItem(2).getDt().addDtItem(new DtItem());// creates and adds text to definition term item 0
defl.getDlItem(2).getDt().getDtItem(0).setContentMix_group(
JavaXMLDocHelper.createTxt("test data 2", false, false, false));
// creates and adds definition list item 3 to definition list
defl.addDlItem(new DlItem()); // creates and adds definition description to defintion list item 3
defl.getDlItem(3).setDd(new Dd()); // creates definition description item
DdItem bdit2s1it1bgrplgrpdlit4ddit1 = new DdItem();// creates and adds definition description item 0 to definition description
defl.getDlItem(3).getDd().addDdItem(new DdItem());
// creates and adds text to definition description item 0
defl.getDlItem(3).getDd().getDdItem(0).setContentMix_group(
JavaXMLDocHelper.createTxt("test definition 2", false, false, false));
// returns definition list
return defl;
}JavaXMLDocHelper is a class with static method to simplify actions which are repeated a lot of times.
i invoke the marshaller in the following manner:
Marshaller m = new Marshaller(fwriter);
m.setDebug(true);
m.marshal(doc);
// doc is the above document (object of class Dl)regards bruno
Arnaud Blandin wrote:
Hi Bruno,
The best is to send the code you use to instantiate your object to the list. According to your schema the <dd/> element is mandatory so I sum up your problem:
- when creating the object by hand and try to marshal you have an exception - when castor is unmarshalling the object and then marshal it back, all is fine
Am I correct?
Arnaud
-----Original Message-----
From: Bruno Cadonna [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 30, 2003 11:43 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] ValidationException: dd is a required field.; doing marshaling
hi,
i sent this email already last week to this mailing list and nobody didn't answer me. maybe i explained my problem not clear enough. anyway i try again!
i have following problem.
due to tests i made a xml-file directly with the generated classes of castor 0.9.5. by creating the objects by myself (using castor's generated classes, but without unmarshalling) and then i marshaled them in order to get the xml-file in xml format.
this is my test xml-file:
<dl> <dt> <txt>test data</txt> </dt> <dd> <txt>test definition</txt> </dd> <dt> <txt>test data 2</txt> </dt> <dd> <txt>test definition 2</txt> </dd> </dl>
the relevant part of my schema is:
<xs:element name="dl"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="dt"/> <xs:element ref="dd"/> </xs:sequence> </xs:complexType> </xs:element>
<xs:element name="dd"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:group ref="content-mix.group"/> </xs:choice> </xs:complexType> </xs:element>
<xs:element name="dt"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:group ref="content-mix.group"/> </xs:choice> </xs:complexType> </xs:element>
when i marshal it i get the exception: ValidationException: dd is a required field.;
but when i change the sequence to a choice (with the same maxOccurs attribute) all works fine.
i tried to unmarshal and then to marshal the xml-file leaving the sequence in the complexType and it works as well.
shouldn't it work also when i create the object by myself?
maybe i forget to set anything, when i create the xml-file as java object.
could somebody help me?
bye bruno
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
