Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 27 +++++++++++++++++++++++++++ dlls/xmllite/writer.c | 8 +++++--- 2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 2cd9cea6cc..5ddb1ef2a7 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1768,6 +1768,33 @@ todo_wine "</p:a>");
IStream_Release(stream); + + /* Define prefix, write attribute with it. */ + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = write_start_element(writer, NULL, "e", NULL); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = write_attribute_string(writer, "xmlns", "prefix", NULL, "uri"); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = write_attribute_string(writer, "prefix", "attr", NULL, "value"); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "got 0x%08x\n", hr); + + CHECK_OUTPUT(stream, + "<e xmlns:prefix="uri" prefix:attr="value" />"); + + IStream_Release(stream); + IXmlWriter_Release(writer); }
diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index bf2a7514ac..8d1fb3a2da 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -843,8 +843,8 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR static const WCHAR xmlnsW[] = {'x','m','l','n','s',0}; static const WCHAR xmlW[] = {'x','m','l',0}; xmlwriter *This = impl_from_IXmlWriter(iface); + BOOL is_xmlns_prefix, is_xmlns_local; int prefix_len, local_len; - BOOL is_xmlns_prefix; struct ns *ns; HRESULT hr;
@@ -879,6 +879,8 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR if (FAILED(hr = is_valid_ncname(local, &local_len))) return hr;
+ is_xmlns_local = !strcmpW(local, xmlnsW); + /* Trivial case, no prefix. */ if (prefix_len == 0 && is_empty_string(uri)) { @@ -918,9 +920,9 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR }
/* Ignore prefix is URI wasn't specified. */ - if (is_empty_string(uri)) + if (is_xmlns_local && is_empty_string(uri)) { - write_output_attribute(This, NULL, 0, local, local_len, value); + write_output_attribute(This, NULL, 0, xmlnsW, ARRAY_SIZE(xmlnsW) - 1, value); return S_OK; }