Hi,

I am now prototyping my software using Jibx as the base. I need to do custom marshalling and unmarshalling of the XML document because the XML has certain dynamic elements inside that changes according to what users will use.

I have a few questions that hopefully you all can help me out with.

1) The method IUnmarshaller.isPresent() exists, but when is this method called or used? And what is the purpose of this method?

2) What is the purpose of the method IUnmarshaller.isExtension()? Can you give me a situation when I would use this method?

3) I have a simply binding file:

<binding>
        <mapping class="ErrorPacket"
                marshaller="ErrorPacketMapper"
                unmarshaller="ErrorPacketMapper"/>
</binding>

Suppose that the error packet is as follows:

<stream:error xmlns:stream="stream:error">
   <blah/>
</stream:error>

When running tests to unmarshall this XML, I get the error:

No unmarshaller for element "{stream:error}error" (line 1, col 62)

Ok, so then I change the binding file to this:

<binding>
        <mapping class="ErrorPacket"
                marshaller="ErrorPacketMapper"
                unmarshaller="ErrorPacketMapper"
                ns="stream:error"/>
</binding>

So now, it will work properly and unmarshalling goes as expected.

Now if I do this:

<binding>
        <namespace prefix="stream" uri="stream:error" default="elements"/>
        <mapping class="ErrorPacket"
                marshaller="ErrorPacketMapper"
                unmarshaller="ErrorPacketMapper"/>
</binding>

It doesn't work the way I wanted, and I get the same error as mentioned above. The following binding file works:

<binding>
        <namespace prefix="stream" uri="stream:error" default="elements"/>
        <mapping class="ErrorPacket"
                marshaller="ErrorPacketMapper"
                unmarshaller="ErrorPacketMapper"
                ns="stream:error"/>
</binding>

I am curious why I have to specify the ns attribute when the namespace should be global and apply to the mapping. Or am I wrong that the <namespace> configuration actually only applies to child elements of the main element?

4) Also, with the above working binding file, I am trying to marshall the object to XML. Supposedly, with the <namespace> specifying stream as prefix, I assume that during marshalling, the MarshallingContext should already contain a mapping that the error element should have the "stream" prefix prepended. However, it doesn't. Debugging and printing out the Namespace Prefix for every index shows null for the URI "stream:error". Why is that? Is there a solution?

5) How do I add add my own Namespace URI in the marshall() method that is not defined in the binding file? Do i add them as extension namespaces?

6) In order to print out the namespace properly, do I have to use the MarshallingContext.startTagNamespaces()?


I hope you can answer some, or all, of the questions I have. It is rather difficult when getting down to the marshalling and unmarshalling code. It's a bit more complicated than just binding files.


Thanks,
Chris



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to