[ http://jira.codehaus.org/browse/JIBX-61?page=comments#action_38035 ] Chris Chen commented on JIBX-61: --------------------------------
I must admit that my situation may be calling a reset() or setOutput() in the middle of a marshalling operation. However, on a more generalized level, what if there was an error during the marshalling stage? For instance, what if the marshalling code throws a JiBXException after opening a start tag but before an end tag is reached? I cannot think of an example at the moment. However, I think the reasoning is not just about calling reset() or setOutput() in the middle of a marshalling operation. If an exception occurs in any way during the marshalling, it would not be possible to reuse the Writer anymore. A new instance would have to be created. When I first saw reset(), I thought that the method is supposed to reset the entire writer back to the original when it was first instantiated (that was sort of my definition of reset) so that it can be reused to marshall another document. Of course, this is the case if the document marshalling was successful each time, but I believe it is not a guarateed situation. Exceptions may possibly occur during marshalling, in which case it would be ideal to reset the writer back to the pristine state. I realize that this is not a bug as you said. My current way is to close off the writer and instantiate a new writer. I figured it would be more efficient if the writer can be recycled and reused under almost any situation. > XMLWriterBase's reset() does not reset namespace prefixes > --------------------------------------------------------- > > Key: JIBX-61 > URL: http://jira.codehaus.org/browse/JIBX-61 > Project: JiBX > Type: Bug > Components: core > Versions: CVS > Reporter: Chris Chen > Assignee: Dennis Sosnoski > > > Say you are writing to an output stream with namespace prefixes. > writer.startTagNamespaces(2, "stream", new int[] { 2, 3 }, new String[] { > "stream", "" }); > When you reset the writer either by calling reset() or setOutput(), the > namespace prefixes are not closed. You must close the tag by calling > endTag() in order for the namespaces to be closed properly. However, it is > not guaranteed that the endTag() will be called for each corresponding > startTagNamespaces(). > The situation can occur either if the stream is unexpectedly closed or if a > setOutput() is explicitly called before writing out the end tag. In such > cases, the namespaces must be closed and resetted in order for the writer to > be reused. Otherwise, the writer will always think those namespaces have > already been defined, thus making the xml writer not recyclable as intended. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------- 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-devs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-devs
