Jay Blanton wrote:
I am reading how to do this in JiBX, but I am a little confused on the
class. I believe the binding file would say something like this
(created through the binding generator):
I've built a some of these as well, so I'll offer some of my examples
and advice.
<?xml version="1.0" encoding="UTF-8"?>
<binding forwards="false" value-style="attribute">
<mapping class="foo.DateTime" marshaller="DateTimeMapper"
unmarshaller="foo.Date"/>
<mapping class="foo.DiagnosisTO" name="diagnosis">
<structure field="date" usage="optional" name="date"/>
<value style="element" name="code" field="code" usage="optional"/>
<value style="element" name="code-type" field="codeType"
usage="optional"/>
</mapping>
</binding>
Problem is that I don't totally understand how to use the
marshal/unmarshal methods described in:
If you could post an example of the xml to be (un)marshalled, it would
help.
For the date/time, you may be going too far into the examples. If the
DateTime is a single field in the XML you may want to look at using
Serializer/Deserilzers.
http://jibx.sourceforge.net/tutorial/binding-custom.html#figure21
In the marshal method (for JiBX), the Object parameter would actually be
representing my DateTime object and I would be creating the XML chunk
where this attribute lives in the Object/XML file. Is that correct? I
ask because I see the startTagAttributes or endTag. Any suggestions?
Also, for a global definition, what does the following information stand
for:
m_uri = null;
m_index = 0;
m_name = null;
m_uri is the URI if the XML namespace. If your XML file uses multiple
namespaces, this is the namespace URI for the element.
m_index is the index of the element name in the JiBX internal data
structures.
m_name is the name of the element which encloses your custom structure.
E.g. if your xml uses <datetime> xxxxx </datetime>, this would be
"datetime".
These are largely used as magic cookies. You should never need to
change them, juss pass them back to the JiBX code.
I see it in the HashMapper example and I can see that it is referenced
in the marshal/unmarshal methods.
This is my first custom mapper in JiBX and I am sure once I write one,
the other ones will be totally easy.
You are correct, writing the mappers isn't difficult. Cut and paste the
class constructors and the isExtension method from the example. You will
need to write the following methods:
public void marshal(Object obj, IMarshallingContext ictx)
throws JiBXException
public Object unmarshal(Object obj, IUnmarshallingContext ictx)
throws JiBXException
If you had an XML example I could show you some code.
--
Thomas Jones-Low Softstart Services Inc.
[EMAIL PROTECTED] JobScheduler for Oracle
Ph: 802-398-1012 http://www.softstart.com
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users