Hi Mark,
This issue of chaining bindings is a problem with the JiBX 1.X
architecture. The setFromContext call was an attempt to provide a
workaround; but looking at the code I can see it won't handle namespaces
properly, since the IXMLWriter tracks those internally. What really
needs to be done is to add a createChildWriter(String[] uris) call to
IXMLWriter, which basically clones the current writer but uses the new
set of namespace URIs. Then this method would be called as part of the
MarshallingContext.setFromContext() call in order to set the writer to
be used within the target MarshallingContext. That's going to break the
IXMLWriter public API, though, and I don't want to do it at this point.
As a kludge, AFAIK every concrete class that implements IXMLWriter has a
constructor that takes the array of namespace URIs as the single
argument. You could do the same as I described above by using reflection
to get the constructor of the IXMLWriter instance for the from context
and calling it using the new array of namespace URIs. Sorry I can't
offer any better solutions for now.
- Dennis
Mark Wutka wrote:
I mentioned in a previos message that I am having some problems with
namespaces. I have a custom marshaller that examines a list for elements
that implement IMarshallable, and when it finds them, it calls
BindingDirectory.getFactory, then creates a marshalling context and
tries to marshall the object. I can't use the marshalling context that
was passed to my marshaller, because it doesn't know anything about the
object I am trying to marshall. If I try to use setFromContext on the
new context to bring in the IXMLWriter from the original context, I get
various errors, ArrayIndexOutOfBounds or NullPointerException.
I think this is because the IXMLWriter maintains a table of namespaces
that is tied to the original binding information and it can't update its
tables with the new object I am trying to marshall. I think this is
caused by the fact that I am generating bindings for these objects
separately instead of putting them all into a single binding file.
My temporary fix was to add a method to StreamWriterBase to let me fetch the
current output stream. I can then just marshall objects to the new
stream and everything works.
I don't think this is a great solution, is there any better option? If
not, would it be possible to officially expose the output stream in
StreamWriterBase ?
Mark
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users