Hi Werner I have created the CASTOR-1977 bug, but I have only attached the files, I do not know how to create a Junit test case nor a patch
Best regards Ander -----Mensaje original----- De: Werner Guttmann [mailto:[EMAIL PROTECTED] Enviado el: jueves, 10 de mayo de 2007 15:20 Para: [email protected] Asunto: AW: [castor-user] [XML] attribute marshalling with location is duplicating elements Now I didn't know that ;-). Well, in that case, it looks Castor is not feature complete :-(. Can I ask you to please open a new Jira issue at http://jira.codehaus.org/browse/CASTOR and attach all relevant files, including domain entities in use, mapping file(s), JUnit test case, etc. And if you followed the guidelines for providing us with a patch that represents the bug report, that would be appreciated. Werner > -----Ursprüngliche Nachricht----- > Von: Ander Garcia Gangoiti [mailto:[EMAIL PROTECTED] > Gesendet: Donnerstag, 10. Mai 2007 12:08 > An: [email protected] > Betreff: RE: [castor-user] [XML] attribute marshalling with location > is duplicating elements > > Hi, > Thanks for your reply. What I do not understand is why it preserves > the structure of the XML when I only use elements and when using > attributes it don´t. For example, if using the following xml it don´t > duplicate elements, i get the same output: > > <?xml version="1.0" encoding="UTF-8"?> > <Person> > <Data1> > <Data2> > <Surname>Garcia</Surname> > > <Data3> > <Name>Ander</Name> > </Data3> > </Data2> > </Data1> > </Person> > > > -----Mensaje original----- > De: Werner Guttmann [mailto:[EMAIL PROTECTED] > Enviado el: jueves, 10 de mayo de 2007 11:57 > Para: [email protected] > Asunto: AW: [castor-user] [XML] attribute marshalling with location is > duplicating elements > > Hi, > > I am not sure whether this is actually possible without creating > separate > (container) classes for <Data1> and <Data2>. When Castor XML marshalls > your Person instance, at runtime it walks through all the field > descriptors and outputs the XML (corresponding to the definitions in > your mapping file). > And > it really does *not* preserve any state between these individual > actions for one field descriptor. > > Regards > Werner > > > -----Ursprüngliche Nachricht----- > > Von: Ander Garcia Gangoiti [mailto:[EMAIL PROTECTED] > > Gesendet: Donnerstag, 10. Mai 2007 11:48 > > An: [email protected] > > Betreff: [castor-user] [XML] attribute marshalling with location is > > duplicating elements > > > > 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 > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

