Hi Daniel, Which version of Castor are you using? I confirm that Castor should support mixed types.
Arnaud > -----Original Message----- > From: Armbrust, Daniel C. [mailto:[EMAIL PROTECTED] > Sent: Monday, June 23, 2003 10:08 PM > To: [EMAIL PROTECTED] > Subject: [castor-dev] Mixed types and Castor > > We have been using Castor for a while now, and just ran into the bug (or > possibly feature request) that Castor cannot handle mixed types. > > Given this schema: > > > > <?xml version="1.0" encoding="UTF-8"?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified"> > <xs:element name="base"> > <xs:complexType> > <xs:sequence> > <xs:element ref="i1" maxOccurs="unbounded"/> > </xs:sequence> > </xs:complexType> > </xs:element> > > <xs:element name="i1"> > <xs:complexType mixed="true"> > <xs:choice minOccurs="0" maxOccurs="unbounded"> > <xs:element ref="i2"/> > </xs:choice> > </xs:complexType> > </xs:element> > > <xs:element name="i2"> > <xs:complexType mixed="true"> > <xs:choice minOccurs="0" maxOccurs="unbounded"> > <xs:element ref="i"/> > </xs:choice> > </xs:complexType> > </xs:element> > > <xs:element name="i" type="xs:string"/> > </xs:schema> > > > > Doing a build and a compile, trying to do an unmarshal results in this > exception: > > > > org.xml.sax.SAXException: Illegal Text data found as child of: _items > value: " embedded" > at > org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java: 690) > at > org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java: 556) > at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unk nown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDis patche > r.dispatch(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unkno wn > Source) > at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) > at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555) > at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:487) > at mixed.Untitled1.main(Untitled1.java:23) > > > We really needed this to work, so we dug in, so to speak, and modified Castor > so that it handles mixed types properly - including returning the elements in > the correct order. > > It can now handle an unmarshal/marshal of the following bit of XML: > > > <?xml version="1.0" encoding="UTF-8"?> > <base xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="C:\work\development\MixedTest\m.xsd"> > <i1>Leading<i2>more > <i>17</i> embedded</i2> > <i2>hereto<i>43</i> > </i2> trailing</i1> > </base> > > > I would be more than happy to commit back the changes (4 classes in > castor.builder [3 modified, 1 new], and 3 classes in castor.xml [all > modified]) so that they could be included in the main source tree. > > We tried to maintain full backwards compatibility, but these changes have > definitely not been tested thoroughly. How should I proceed? I can send back > a .jar file of my modified version of castor, so you could run whatever > regression tests you have on it... Or I can send you the modified files, or I > can send you some CVS diffs (or all of the above) They may also be a bit more > hackish in places than the maintainers would like... You will have to let me > know. > > Please advise, > > Thanks, > > Dan > > ----------------------------------------------------------- > 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