Ruben Fragoso wrote:

> here is an example of the message that i get
> 
> only START_TAG can have attributes END_TAG seen ... <MyCustomObject
> widht="23" type="TypeOne" name="One" heigh="23"/>... @3:68 : only
> START_TAG can have attributes END_TAG seen ... <MyCustomObject widht="23"
> type="TypeOne" name="One" heigh="23"/>... @3:68

You test case does not produce this error. However, if the fragment of the 
first switch would have been executed, you get this. Let's simply assume, 
your code does not contain the condition for the empty XML value right after 
the move down:

================ %< ==============
<MyCustomObject>
  <MyCustomObject widht="45" type="TypeThree" name="Three" 
diameter="78"|></MyCustomObject>
  <MyCustomObject widht="23" type="TypeOne" name="One" 
heigh="23"></MyCustomObject>
================ %< ==============

Next would have been:

================ %< ==============
                            reader.moveUp();
================ %< ==============
<MyCustomObject>
  <MyCustomObject widht="45" type="TypeThree" name="Three" 
diameter="78"></MyCustomObject>|
  <MyCustomObject widht="23" type="TypeOne" name="One" 
heigh="23"></MyCustomObject>
================ %< ==============

You moved the pointer after the element's closing tag and now you suddenly 
try to process this tag by calling another converter, but actually the XML 
stream is now in an undefined state for this converter:

================ %< ==============
                            ExtendedTypeOne extendedTypeOne = new 
ExtendedTypeOne();
                            extendedTypeOne = 
(ExtendedTypeOne)uc.convertAnother(
                                extendedTypeOne, ExtendedTypeOne.class);
================ %< ==============

What you actually want is:

================ %< ==============
MyCustomObject returnValue = new MyCustomObject();
while (reader.hasMoreChildren()) {
    reader.moveDown();
    // check now for the tag name, if you want to be sure it is 
"MyCustomObject"
    MyBaseClass.Type type = 
MyBaseClass.Type.valueOf(reader.getAttribute("type"));
    MyBaseClass base = null;
    switch (type) {
        case TypeOne: {
            base = (ExtendedTypeOne)uc.convertAnother(
                returnValue, ExtendedTypeOne.class);
            break;
        }
        case TypeTwo: {
        }
        default: {
        }
    }
    reader.moveUp();
    returnValue.put(???, base);
}
return returnValue;
================ %< ==============

And now compare this with your code in the marshall method. All calls to the 
reader have their exact equivalent with the ones to the writer. Also note 
the parameters for the call to call another converter.

- Jörg


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

    http://xircles.codehaus.org/manage_email


Reply via email to