If a Result created from an XMLEventWriter is passed to a JibxMarshaller for marshalling, then the following happens:
- AbstractMarshaller.marshal() delegates to AbstractMarshaller.marshalStaxResult()
- AbstractMarshaller.marshalStaxResult() delegates to JibxMarshaller.marshalXmlEventWriter()
- JibxMarshaller.marshalXmlEventWriter() creates a ContentHandler from the XMLEventWriter and then proceeds.
The problem here is that the ContentHandler is a "logical view" API, not a "document view" API and (for example) does not support comments.
So if you marshal a document containing comments, they are silently deleted.
This is a bug: it is not appropriate to assume that comments are discardable.