Why do you think you need to write the object tag before you call toXmlStream()?