Hi,
No problem! As it happens you can use a similar SAX based solution with the Unmarshaller also! Create your own DocumentHandler implementation, give this to your SAX parser and start parsing.
When you receive the startElement event for <Person>, create an Unmarshaller class and call the getDocumentHandler() method (an instance of UnmarshallerHandler is returned). Then begin forwarding the SAX events to this handler (starting with the event you just received) upto and including the endElement event for <Person>. Then it's matter of calling the getObject method on the Castor hanlder to get your object.
We use this solution to process a SAX message stream from our client, that contains various header and request parts. This allows us to handle very large requests in streamed fashion and still enjoy the benefits of Castor!
Hope this helps, have fun!
Andy.
-----Original Message-----
From: Folker Hagen [mailto:[EMAIL PROTECTED]]
Sent: 12 August 2001 20:47
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] castor xml-marshalling
hi.
now my problem still remains for the unmarshalling :-(
i don't want to use the vector-construct (shown on the web-site) to
unmarshal two or more instances of one class.
is that possible, do i have to provide a mapping-file, or is there any
other way?
thanks a lot
folker
Andrew Fawcett schrieb am 06.08.2001 um 09:24 :
>You could try directing the output of the Marshaller to a SAX document
>handler that serialises XML (such as
>org.apache.xml.serialize.XMLSerializer). First start your document and
send
>your root node, e.g. handler.startDocument();
>handler.startElement("Persons", ...) then marshal each Person object. Be
>sure to use the setMarshalAsDocument(false) method each time. Finally end
>your document, e.g. handler.endElement("Persons"; handler.endDocument();
>
>-----Original Message-----
>From: Folker Hagen [mailto:[EMAIL PROTECTED]]
>Sent: 04 August 2001 12:13
>To: [EMAIL PROTECTED]
>Subject: [castor-dev] castor xml-marshalling
>
>
>hi.
>i have a problem with castors xml marshalling.
>how is it possible to get two instances of a class(for example the
>person example on the web site, class Person, instance person1 and
>person2) into the same xml-file?
>i tried to call the marshaller twice, but only the following happened to
>the file:
>
><?xml version="1.0"?>
><person><name>Folker Hagen</name></person>
><?xml version="1.0"?>
><person><name>Wolfgang Lehner</name></person>
>
>thanks for answering
>
>folker
>
>-----------------------------------------------------------
>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
*********** snip ***********
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
