xmllite/writer: Fix writing prefixed attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
55af98d1a3
commit
b11f43d568
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue