Dennis Sosnoski wrote:

The class attribute is only used with a <mapping> element. The current code doesn't check for unknown attributes, so it won't complain if you add in something that's not relevant. That's the case for your class attribute on the <structure> element. If you remove this attribute everything should work the same.


For beta 4 I'll be checking for unknown attributes, just to avoid the confusion factor this causes for users.

You are correct. It works without the class="Address" element. Which implies JiBX is smart enough to decipher the class of the field element, and instantiate it correctly. But if the Address class requires special processing, it won't work correctly.

Having the bind compiler complain about unknown attributes would be a good thing, as I have a problem with spelling...

As I understand it you have a collection of <secondary>s, not a <secondary> that contains a collection of <primary> (which is what the above binding definition says). This approach should work if you structure the binding properly, which would be:

<structure field="primary" map-as="Address"/>
<collection field="secondary" usage="optional">
<structure name="secondary" using="ADDRESS"/>
</collection>

No guarantees on this, though, since the whole label/using approach has some broken pieces - that's why it's going to be replaced with a more stable alternative.


Nope, this fails with during the compile with:
[java] org.jibx.runtime.JiBXException: Reference to structure ADDRESS has object of type java.lang.Object rather than required Address [java] at org.jibx.binding.def.StructureReference.setLinkages(StructureReference.java:120)


As for the "correct" way, JiBX actually gives you multiple alternatives in most cases. The binding further up is fine; I think you should also be able to define the Address class with a <mapping abstract="true"...> which doesn't specify a name, then fill in the name on the references to it:

<structure field="primary" name="primary" map-as="Address"/>
<collection field="secondary" usage="optional">
<structure name="secondary" map-as="Address"/>
</collection>

        This also fails during the bind with the following error:

[java] org.jibx.runtime.JiBXException: Name not allowed when using mapping reference at tag "structure"(line 4, col 35, in bind.xml)
[java] at org.jibx.runtime.impl.UnmarshallingContext.throwStartTagException(UnmarshallingContext.java:2725)



The label/using approach also works, though this will need to change in the future.

Since this seems to work properly, I'll use this and wait for the beta-4 release and fix the binding files again.

--
        Thomas Jones-Low            Softstart Services Inc.
        [EMAIL PROTECTED]      JobScheduler for Oracle
        Ph: 802-398-1012            http://www.softstart.com




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to