Hi Jerôme, Your suggestion are not real solutions, but rather work arround solutions. The first one is not applicable because, i don't know by advance if the object "b" and "c" reference the same object "a" or not. The second one is not applicable too, because a can't modified ma business objects only for have the missing xml of the referenced object.
Please let's me know if i misunderstand, but it seems castor XML doesn't know manage completly by itself the reference IDREFs... Thanks to you. Christian -----Original Message----- From: Pastre Jerôme [mailto:[EMAIL PROTECTED] Sent: mardi 30 mars 2004 15:09 To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Marshalling problem using reference IDREFs (suite) Nicolas First solution what 's going on if you change your mapping file like this : <class name="test.server.B" auto-complete="true"> <map-to xml="B"/> </class> Second solution you need to define the object "a" in classD in order to marshall it and then it could be referenced. -----Message d'origine----- De : Nicolas Christian [mailto:[EMAIL PROTECTED] Envoyé : mardi 30 mars 2004 11:27 À : '[EMAIL PROTECTED]' Objet : Re: [castor-dev] Marshalling problem using reference IDREFs (suite) Hi Jerôme, I have tried your suggestion but unfortunatly it does not work, the xml description of the object "a" still missing. Hereafter the xml result: <?xml version="1.0" encoding="UTF-8"?> <D> <b a="15"> <type>XX25</type> </b> <number>123</number> <c a="15"> <category>C3</category> </c> </D> -----Original Message----- From: Pastre Jerôme [mailto:[EMAIL PROTECTED] Sent: lundi 29 mars 2004 14:12 To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Marshalling problem using reference IDREFs (suite) Nicolas, Is it working if you remove name="REF_A" in <bind-xml name="REF_A" reference="true" node="attribute" /> --Jerome -----Message d'origine----- De : Nicolas Christian [mailto:[EMAIL PROTECTED] Envoyé : lundi 29 mars 2004 11:55 À : [EMAIL PROTECTED] Cc : Jerid Lahcen; Corriou Michel Objet : [castor-dev] Marshalling problem using reference IDREFs (suite) I have an Marshalling problem using reference IDREFs. Context: I have 2 object "b" and "c" which references the same object "a", and the object "d" which contains "b" and "c". When i marshal the object "d", the xml data contains "d", "b" and "c" but the referenced object "a" is missing, i don't understand why ? My simple source code: public class A { private int m_reference; private String m_name; public void setReference(int _reference) { m_reference = _reference; } public int getReference(){ return m_reference; } public void setName(String _name) { m_name = _name; } public String getName() { return m_name; } public A() { } } public class B { private String m_type; private A m_a; public void setType(String _type) { m_type = _type; } public String getType() { return m_type; } public void setA(A _a) { m_a = _a; } public A getA() { return m_a; } public B() { } } public class C { private String m_category; private A m_a; public void setCategory(String _category) { m_category = _category; } public String getCategory() { return m_category; } public void setA(A _a) { m_a = _a; } public A getA() { return m_a; } public C() { } } public class D { private int m_number; private B m_b; private C m_c; public void setNumber(int _number) { m_number = _number; } public int getNumber() { return m_number; } public void setB(B _b) { m_b = _b; } public B getB() { return m_b; } public void setC(C _c) { m_c = _c; } public C getC() { return m_c; } public D() { } } package test; import test.server.*; import java.io.*; import org.exolab.castor.xml.*; import org.exolab.castor.mapping.*; public class OnServerSide { private Mapping m_mapping = XMappingLoader.Load("Mapping.xml"); private D m_d; public OnServerSide() { A a = new A(); a.setReference(15); a.setName("TOTO"); B b = new B(); b.setType("XX25"); b.setA(a); C c = new C(); c.setCategory("C3"); c.setA(a); m_d = new D(); m_d.setNumber(123); m_d.setB(b); m_d.setC(c); } public void marshall() { byte[] xmlData = null; try { // Create a byte array output stream. ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(baos); // Create a new castor marshaller. Marshaller marshaller = new Marshaller(outputStreamWriter); // Note the resolver must be set before the mapping, otherwise // the mapping will be ignored. if (m_mapping != null) { marshaller.setMapping(m_mapping); } marshaller.marshal(m_d); xmlData = baos.toByteArray(); baos.flush(); baos.close(); // Trace: System.out.println("*** Marshalling completed successfully ***"); System.out.println(new String(xmlData)); } catch (Exception e) { System.out.println("Marshalling failed !"); } } public static void main(String args[]) { OnServerSide tester = new OnServerSide(); tester.marshall(); } } My simple mapping file: <?xml version="1.0"?> <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd"> <mapping> <class name="test.server.A" auto-complete="true" identity="reference"> <map-to xml="A"/> <field name="reference" type="int"> <bind-xml node="attribute" /> </field> </class> <class name="test.server.B" auto-complete="true"> <map-to xml="B"/> <field name="a" type="test.server.A"> <bind-xml name="REF_A" reference="true" node="attribute" /> </field> </class> <class name="test.server.C" auto-complete="true"> <map-to xml="C"/> <field name="a" type="test.server.A"> <bind-xml name="REF_A" reference="true" node="attribute" /> </field> </class> <class name="test.server.D" auto-complete="true"> <map-to xml="D"/> </class> </mapping> The result of the marshalling where the object a is missing: <?xml version="1.0" encoding="UTF-8"?> <D> <b REF_A="15"> <type>XX25</type> </b> <number>123</number> <c REF_A="15"> <category>C3</category> </c> </D> Do you have any suggestion about my problem ? ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev