There's a distinction here that I should clarify. The serializer/deserializer approach Angel suggests is only for converting values to and from simple text strings (the values of attributes, the content of elements, etc.). For actually creating elements you need to use a custom marshaller/unmarshaller, which is a little more involved. The marshaller/unmarshaller gets called by JiBX to handle the full conversion of a particular object type to and from XML.

For the case Tim asks about, a custom marshaller could do this easily. The marshaller would just need to get the tag name and contents from the object being marshalled and write them to the supplied marshalling context. I think you could do the inverse with an unmarshaller, though I haven't tried anything like this. Check the tutorial and org.jibx.extras code for more on working with custom marshaller/unmarshallers.

 - Dennis

???e??? ?a???t?a??? wrote:

You can tell JiBX in the binding definition to use a method of your own to
do the marshalling.

The method must be something like this:
   public static String <methodName>(Object obj)

and you tell it in the binding definition like this :

<value name="data" field="data"
               serializer="<some class name that contains your marshalling
method>.<methodName as above, without the parentheses>"

Be careful to specify the complete class name, packages included.
You do exactly the same if you want to use a custom un-marshaller.

Hope this helps,
Angel
O:]

----- Original Message ----- From: "Tim Sawyer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 06, 2004 1:25 PM
Subject: [jibx-users] Manual Marshalling





Hi,

I would like to manually implement the marshal method in a class, to take


the


tag name and contents from the class I am on.

So if I have two attributes, this.tagname which contains TAGNAME and
this.tagcontents which contains CONTENTS I would like to output

<TAGNAME>CONTENTS</TAGNAME>

I'm not sure how to deal with the passed in IMarhsllingContext to get this


to


work.

Is this possible?

Cheers,

Tim.




------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to