Hi Dennis,
  I think I run into the same problem this way that I do with my
temporary solution. That is, in order to create a new StreamWriterBase
and make it write to the current output stream, I need to be able to
fetch the current output stream.
In my current solution, with the added getOutputStream in
StreamWriterBase, all I have to do is:

OutputStream out = ((StreamWriterBase) writer).getOutputStream();
newMCtx.marshalDocument(o, "UTF-8", null, out);

I was hoping that you might be able to expose getOutputStream
officially so I am not trying to maintain my own fork of the code.
  Mark

" 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
" 

-- 
Got Love, Joy, Peace, Patience, Kindness, Goodness,
   Faithfulness, Gentleness, and Self-control?


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to