Hi,

I am unmarshalling  and marshalling some XML docs and classes and when I
have and attribute inside a "foo" element, castor is duplication the
elements located on the path to the attribute. 

I have created a simple example to explain better what is happening.

---This is the original XML doc, where Data1, Data2 and Data 3 are "foo"
elements:

<?xml version="1.0" encoding="UTF-8"?>
        <Person>      
                <Data1>
                        <Data2>
                                <Surname>Garcia</Surname>

                                <Data3>
                                        <Name a="Ander"></Name>         
                                </Data3>
                        </Data2>                        
                </Data1>
    </Person>

---This is Person class:

package castor;

public class Person {

        private String _name; 
         public java.lang.String getName(
            ) {
                return this._name;
            }
            public void setName(
                    final String name) {
                this._name = name;
            }  
            
            private String _surname; 
                 public java.lang.String getSurname(
                    ) {
                        return this._surname;
                    }
                    public void setSurname(
                            final String surname) {
                        this._surname = surname;
                    }  
}

---This is the mapping file:

<?xml version="1.0" encoding="UTF-8"?>
<mapping  >
<class  name="castor.Person" >
        <description>Mapping for class castor.Person</description>
        <map-to xml="Person"/>          
        <field name="name" type="string" >            
            <bind-xml node="attribute" name="a"
location="Data1/Data2/Data3/Name" />
        </field>        
        <field name="surname" type="string" >            
            <bind-xml node="element" name="Surname" location="Data1/Data2"
/>
        </field>                                        
        </class>
</mapping>

---And this is the xml output I get:

<?xml version="1.0" encoding="UTF-8"?>
<Person>
    <Data1>
        <Data2>
            <Surname>Garcia</Surname>
        </Data2>
    </Data1>
    <Data1>
        <Data2>
            <Data3>
                <Name a="Ander"/>
            </Data3>
        </Data2>
    </Data1>
</Person>

Is it possible to get Castor not to duplicate Data1 and Data2 when
marshalling the attribute? If instead of being an attribute I use only
elements, I do not get duplicates elements.

Thank you very much.

Ander Garcia


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

    http://xircles.codehaus.org/manage_email

Reply via email to