Hi Ruben,

Ruben Fragoso wrote:

> Hello Jorg
> 
> Thank you for coming back to me.
> 
> So i test the following piece of code (following you suggestion):
> 
> =============================
> while (reader.hasMoreChildren()) {
>             MyBaseClass.Type type =
> MyBaseClass.Type.valueOf(reader.getAttribute("type"));
>             MyBaseClass base = null;
>             reader.moveDown();
>             switch (type) {
>                 case TypeOne: {
>                     base = (ExtendedTypeOne) uc.convertAnother(
>                             returnValue, ExtendedTypeOne.class);
>                 }
>                 case TypeTwo: {
>                 }
>                 default: {
>                 }
>             }
>             reader.moveUp();
>             if (null != base) {
>                 returnValue.put(base.getName(), base);
>             }
>         }
> 
> 
> 
> ==========================

You still read the type attribute in advance.

> It gave me the same exception that i mentioned previously, about the
> START_TAG and END_TAG

Works for me. Seems we're not talking about the same code.
 
> Now one thing that i noticed is the following: if i inspect the reader
> object when it enters the case, i notice that the element "parser" inside
> the reader, has the entire XML objected side, with the right number of
> attributes and with the all the attributes names correct. and that the
> element "buf" inside the parser has the complete xml inside.

XStream uses a big variety of parsers and all are 3rd party. We have 
absolutely no control about the parsers internal functionality and we may 
not even care. Under no circumstance.

> There are several things which i don't understand:
> 
> 1. why can't i get the XML string, as i don't see any method to retrieve
> the XML of the current element in which the reader parsed and is currently
> on (as in at the end of the element as you explained before).

Which XML? XStream can read also JSON or a compressed internal binary 
format.

> 2. I don't understand that if the reader already went through the xml
> element and has everything parsed, why in the uc.convertAnother, we have
> to reference its parent object.

You can even use 'null'. The parameter is used for XStream's internal 
housekeeping to detect loops.
 
> 3. should i use the version (convertAnother(Object o, Class type,
> Converter cnvrtr); instead of the convertAnother(Object o, Class type) ?

The former. The latter is for special use case (i.e. when you know what 
you're doing).

> Hope to hear from you and Thank you in advance :)

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to