Rob- Sorry, guess I wasn't clear. You are correct, the Castor UnmarshalHandler receives events from a SAX parser and unmarshals the elements based on those events.
My idea was to create your own implementation of ContentHandler that would wrap the Castor UnmarshalHandler. That way, when the parser fires an event such as startElement, your ContentHandler receives the event first, can examine the element in question, and decide whether or not Castor should see the event. If you do want to unmarshal that element you pass the event on to the UnmarshalHandler. Otherwise you just don't do anything and allow parsing to continue. One snafu I can see with this method is that the UnmarshalHandler does keep an internal state based on the set of events it has received. That state could get corrupted if you only call startElement on the root element and then some element nested several layers down in the XML. But I think if you call startElement and endElement for each element in the hierarchy of the element(s) you are interested in, you should be okay. Does that make more sense? Stephen On 3/29/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Thanks for the response. I looked into the content handler but I don't think > one can control what gets un/marshalled from it. I think it's used to process > data as it gets un/marshalled. > > I'll post if I find anything to address the problem. > > > Rob > > ------------------------------------------ > Robert Lerner > Senior Consultant > Vichara Technologies, Inc > 646-344-3541 > > > > > "Stephen Bash" <[EMAIL PROTECTED]> > > 03/29/2006 08:57 AM > > Please respond to > [email protected] > > > To [email protected] > > cc > > > Subject Re: [castor-user] Filtering while unmarshalling collections > > > > > > > > > Rob- > > It probably isn't too helpful, but my first reaction would be to use > an XQuery processor to slice up the XML file and then unmarshal the > result in Castor. You might look into the listener interfaces in > Castor (I'm thinking UnmarshalListener), but I don't think those offer > any control, just event notification. Another option is to create a > ContentHandler that sits between the parser and Castor that only sends > Castor the events that you want it to receive. There might be an > easier way to do this, but those are the off-the-top-of-my-head > solutions... > > If you get a solution that works, please let us know, as it will > probably help others in the future. > > Stephen > > > On 3/28/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I'm unmarshalling an xml in which there can be multiple instances of the > > same node-type. Within each node is an identifying string that tells me to > > what the information contained in the node pertains. I only need > information > > from one node with a particular identifying string. Is there any way to > > check that string prior to the unmarshalling? In other words, I want to > > avoid unmarshalling all the nodes into a collection of objects and looking > > for the specific string by iterating through the collection. I'd rather > > check before the unmarshalling so I only one object (that corresponds to > > that node) gets instantiated. > > > > Any ideas? > > > > Thanks, > > Rob > > > > ----------------------------------------- > > Robert Lerner > > Senior Consultant > > Vichara Technologies, Inc > > 646-344-3541 > > > > ________________________________ > > > > > > > > > > > > > > ******************************************************************* > > **** > > This E-mail is confidential. It may also be legally privileged. If > > you > > are not the addressee you may not copy, forward, disclose or use > > any > > part of it. If you have received this message in error, please > > delete > > it and all copies from your system and notify the sender > > immediately > > by return E-mail. > > > > Internet communications cannot be guaranteed to be timely, secure, > > error or virus-free. The sender does not accept liability for any > > errors or omissions. > > ******************************************************************* > > **** > > > > > > ----------------------------------------- > ****************************************************************** > This message originated from the Internet. Its originator may or > may not be who they claim to be and the information contained in > the message and any attachments may or may not be accurate. > ****************************************************************** > > > > > ________________________________ > > > > > > ******************************************************************* > **** > This E-mail is confidential. It may also be legally privileged. If > you > are not the addressee you may not copy, forward, disclose or use > any > part of it. If you have received this message in error, please > delete > it and all copies from your system and notify the sender > immediately > by return E-mail. > > Internet communications cannot be guaranteed to be timely, secure, > error or virus-free. The sender does not accept liability for any > errors or omissions. > ******************************************************************* > **** >

