static HRESULT write_xmldecl(xmlwriter *writer, XmlStandalone standalone) { static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"'}; static const WCHAR encodingW[] = {' ','e','n','c','o','d','i','n','g','='}; write_encoding_bom(writer); writer->state = XmlWriterState_DocStarted; if (writer->omitxmldecl) return S_OK; /* version */ write_output_buffer(writer->output, versionW, ARRAY_SIZE(versionW)); /* encoding */ write_output_buffer(writer->output, encodingW, ARRAY_SIZE(encodingW)); write_output_buffer_quoted(writer->output, get_encoding_name(writer->output->encoding), -1); /* standalone */ if (standalone == XmlStandalone_Omit) write_output_buffer(writer->output, closepiW, ARRAY_SIZE(closepiW)); else { static const WCHAR standaloneW[] = {' ','s','t','a','n','d','a','l','o','n','e','=','\"'}; static const WCHAR yesW[] = {'y','e','s','\"','?','>'}; static const WCHAR noW[] = {'n','o','\"','?','>'}; write_output_buffer(writer->output, standaloneW, ARRAY_SIZE(standaloneW)); if (standalone == XmlStandalone_Yes) write_output_buffer(writer->output, yesW, ARRAY_SIZE(yesW)); else write_output_buffer(writer->output, noW, ARRAY_SIZE(noW)); } return S_OK; }
static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandalone standalone) { static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"'}; static const WCHAR encodingW[] = {' ','e','n','c','o','d','i','n','g','='}; xmlwriter *This = impl_from_IXmlWriter(iface); TRACE("(%p)->(%d)\n", This, standalone); switch (This->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_PIDocStarted: This->state = XmlWriterState_DocStarted; return S_OK; case XmlWriterState_DocStarted: case XmlWriterState_ElemStarted: case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; default: ; } write_encoding_bom(This); This->state = XmlWriterState_DocStarted; if (This->omitxmldecl) return S_OK; /* version */ write_output_buffer(This->output, versionW, ARRAY_SIZE(versionW)); /* encoding */ write_output_buffer(This->output, encodingW, ARRAY_SIZE(encodingW)); write_output_buffer_quoted(This->output, get_encoding_name(This->output->encoding), -1); /* standalone */ if (standalone == XmlStandalone_Omit) write_output_buffer(This->output, closepiW, ARRAY_SIZE(closepiW)); else { static const WCHAR standaloneW[] = {' ','s','t','a','n','d','a','l','o','n','e','=','\"'}; static const WCHAR yesW[] = {'y','e','s','\"','?','>'}; static const WCHAR noW[] = {'n','o','\"','?','>'}; write_output_buffer(This->output, standaloneW, ARRAY_SIZE(standaloneW)); if (standalone == XmlStandalone_Yes) write_output_buffer(This->output, yesW, ARRAY_SIZE(yesW)); else write_output_buffer(This->output, noW, ARRAY_SIZE(noW)); } return S_OK; }