I just built out a JAXB data binding codebase for a massive XML schema that we use for EDI.  But I don't like the way JAXB locks its implementation into the codebase and so I want to look at a mapper such as JiBX for speed and simplicity (since I can just do validation through SAXParser).  I have quite a few custom classes that are referenced in my objects, such as a custom date/time object called DateTime, and quite a few TypeSafeEnumerations custom classes (before JDK 1.5).  Anyways, I created quite a few converters in JAXB that I can use to transform a Java Calendar (schema default) into my DateTime and back from my DateTime into the Java Calendar.  I was able to provide a rule in the binding file that all xsd:date elements should use this converter.

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):

<?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:

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;

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.

But I have about 30+ converters in JAXB...so I would probably need the same in JiBX.

Thanks,

--
jay blanton
[EMAIL PROTECTED]
(c) 916-715-1529

Reply via email to