From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 92e6f460326..6baff9d8a23 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -2508,6 +2508,8 @@ static void test_WriteDocType(void) doctype_tests[] = { { L"a", L"", NULL, NULL, "<!DOCTYPE a PUBLIC \"\" \"\">" }, + { L"a.b", L"", NULL, NULL, "<!DOCTYPE a.b PUBLIC \"\" \"\">" }, + { L"a-b", L"", NULL, NULL, "<!DOCTYPE a-b PUBLIC \"\" \"\">" }, { L"a", NULL, NULL, NULL, "<!DOCTYPE a>" }, { L"a", NULL, L"", NULL, "<!DOCTYPE a SYSTEM \"\">" }, { L"a", L"", L"", NULL, "<!DOCTYPE a PUBLIC \"\" \"\">" },
From: David Kahurani k.kahurani@gmail.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/writer.c | 13 +++---------- dlls/xmllite/writer.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 6baff9d8a23..d3263c6911d 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -3294,11 +3294,9 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"", L"cd"); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, NULL, L"cd"); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"xyz@xyz"); @@ -3315,7 +3313,6 @@ static void test_WriteQualifiedName(void) writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration);
hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"cd"); - todo_wine ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr);
IStream_Release(stream); @@ -3328,7 +3325,6 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"a@b", L"cd"); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); @@ -3347,13 +3343,12 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"de"); - todo_wine ok(hr == WR_E_NAMESPACEUNDECLARED, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<ab:a xmlns:ab="cd">");
IStream_Release(stream); @@ -3371,7 +3366,6 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"xy", L"cd"); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -3380,7 +3374,7 @@ static void test_WriteQualifiedName(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<a xmlns="cd"><b xmlns="gh">xy</b></a>");
IStream_Release(stream); @@ -3396,7 +3390,6 @@ static void test_WriteQualifiedName(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L"xy", L"cd"); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteEndDocument(writer); @@ -3405,7 +3398,7 @@ static void test_WriteQualifiedName(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<ab:a xmlns:ab="cd"><ef:b xmlns:ef="gh">ab:xy</ef:b></ab:a>");
IStream_Release(stream); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 76b4afafbb5..bd315532629 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1858,26 +1858,48 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP return hr; }
-static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, LPCWSTR pwszLocalName, - LPCWSTR pwszNamespaceUri) +static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, + const WCHAR *local_name, const WCHAR *uri) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + struct ns *ns; + int local_len; + HRESULT hr;
- FIXME("%p %s %s\n", This, wine_dbgstr_w(pwszLocalName), wine_dbgstr_w(pwszNamespaceUri)); + TRACE("%p, %s, %s.\n", iface, wine_dbgstr_w(local_name), wine_dbgstr_w(uri));
- switch (This->state) + if (is_empty_string(local_name)) + return E_INVALIDARG; + + if (FAILED(hr = is_valid_ncname(local_name, &local_len))) + return hr; + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; + case XmlWriterState_Ready: case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; + case XmlWriterState_ElemStarted: + if (FAILED(hr = writer_close_starttag(writer))) return hr; + break; default: ; }
- return E_NOTIMPL; + if (!(ns = writer_find_ns(writer, NULL, uri))) + return WR_E_NAMESPACEUNDECLARED; + + if (ns->prefix) + { + write_output(writer, ns->prefix, ns->prefix_len, &hr); + write_output(writer, L":", 1, &hr); + } + + return write_output(writer, local_name, local_len, &hr); }
static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/writer.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index bd315532629..ac5e2d6150d 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -962,13 +962,18 @@ static HRESULT WINAPI xmlwriter_WriteAttributes(IXmlWriter *iface, IXmlReader *r return hr; }
-static void write_output_attribute(xmlwriter *writer, const WCHAR *prefix, int prefix_len, - const WCHAR *local, int local_len, const WCHAR *value) +static HRESULT write_output_attribute(xmlwriter *writer, const WCHAR *prefix, int prefix_len, + const WCHAR *local, int local_len, const WCHAR *value, HRESULT *hr) { - write_output_buffer_char(writer->output, ' '); + if (FAILED(*hr)) + return *hr; + + write_output(writer, L" ", 1, hr); write_output_qname(writer->output, prefix, prefix_len, local, local_len); - write_output_buffer_char(writer->output, '='); - write_output_buffer_quoted(writer->output, value, -1); + write_output(writer, L"=", 1, hr); + write_output_quoted(writer, value, -1, hr); + + return *hr; }
static BOOL is_valid_xml_space_value(const WCHAR *value) @@ -1020,10 +1025,7 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR
/* Trivial case, no prefix. */ if (prefix_len == 0 && is_empty_string(uri)) - { - write_output_attribute(writer, prefix, prefix_len, local, local_len, value); - return S_OK; - } + return write_output_attribute(writer, prefix, prefix_len, local, local_len, value, &hr);
/* Predefined "xml" prefix. */ if (prefix_len && !wcscmp(prefix, L"xml")) @@ -1036,9 +1038,7 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR if (!is_empty_string(uri)) return WR_E_XMLPREFIXDECLARATION;
- write_output_attribute(writer, prefix, prefix_len, local, local_len, value); - - return S_OK; + return write_output_attribute(writer, prefix, prefix_len, local, local_len, value, &hr); }
if (is_xmlns_prefix || (prefix_len == 0 && uri && !wcscmp(uri, xmlnsuriW))) @@ -1051,17 +1051,12 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR ns = writer_push_ns(writer, local, local_len, value); ns->emitted = TRUE;
- write_output_attribute(writer, L"xmlns", 5, local, local_len, value); - - return S_OK; + return write_output_attribute(writer, L"xmlns", 5, local, local_len, value, &hr); }
/* Ignore prefix if URI wasn't specified. */ if (is_xmlns_local && is_empty_string(uri)) - { - write_output_attribute(writer, NULL, 0, L"xmlns", 5, value); - return S_OK; - } + return write_output_attribute(writer, NULL, 0, L"xmlns", 5, value, &hr);
if (!(ns = writer_find_ns(writer, prefix, uri))) { @@ -1075,11 +1070,11 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR }
if (ns) - write_output_attribute(writer, ns->prefix, ns->prefix_len, local, local_len, value); + hr = write_output_attribute(writer, ns->prefix, ns->prefix_len, local, local_len, value, &hr); else - write_output_attribute(writer, prefix, prefix_len, local, local_len, value); + hr = write_output_attribute(writer, prefix, prefix_len, local, local_len, value, &hr);
- return S_OK; + return hr; }
static HRESULT write_cdata_section(xmlwriter *writer, const WCHAR *data, int len)
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/writer.c | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index ac5e2d6150d..3c761be23a1 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -566,20 +566,18 @@ static HRESULT write_output_buffer_quoted(xmlwriteroutput *output, const WCHAR * }
/* TODO: test if we need to validate char range */ -static HRESULT write_output_qname(xmlwriteroutput *output, const WCHAR *prefix, int prefix_len, - const WCHAR *local_name, int local_len) +static HRESULT write_output_qname(xmlwriter *writer, const WCHAR *prefix, int prefix_len, + const WCHAR *local_name, int local_len, HRESULT *hr) { assert(prefix_len >= 0 && local_len >= 0);
if (prefix_len) - write_output_buffer(output, prefix, prefix_len); + write_output(writer, prefix, prefix_len, hr);
if (prefix_len && local_len) - write_output_buffer_char(output, ':'); + write_output(writer, L":", 1, hr);
- write_output_buffer(output, local_name, local_len); - - return S_OK; + return write_output(writer, local_name, local_len, hr); }
static void writeroutput_release_stream(xmlwriteroutput *writeroutput) @@ -690,8 +688,9 @@ static HRESULT write_xmldecl(xmlwriter *writer, XmlStandalone standalone, HRESUL return *hr; }
-static void writer_output_ns(xmlwriter *writer, const struct element *element) +static HRESULT writer_output_ns(xmlwriter *writer, const struct element *element) { + HRESULT hr = S_OK; struct ns *ns;
LIST_FOR_EACH_ENTRY(ns, &element->ns, struct ns, entry) @@ -699,10 +698,12 @@ static void writer_output_ns(xmlwriter *writer, const struct element *element) if (ns->emitted) continue;
- write_output_qname(writer->output, L" xmlns", 6, ns->prefix, ns->prefix_len); - write_output_buffer_char(writer->output, '='); - write_output_buffer_quoted(writer->output, ns->uri, -1); + write_output_qname(writer, L" xmlns", 6, ns->prefix, ns->prefix_len, &hr); + write_output(writer, L"=", 1, &hr); + write_output_quoted(writer, ns->uri, -1, &hr); } + + return hr; }
static HRESULT writer_close_starttag(xmlwriter *writer) @@ -711,10 +712,9 @@ static HRESULT writer_close_starttag(xmlwriter *writer)
if (!writer->starttagopen) return S_OK;
- writer_output_ns(writer, LIST_ENTRY(list_head(&writer->elements), struct element, entry)); - hr = write_output_buffer_char(writer->output, '>'); writer->starttagopen = 0; - return hr; + hr = writer_output_ns(writer, LIST_ENTRY(list_head(&writer->elements), struct element, entry)); + return write_output(writer, L">", 1, &hr); }
static void writer_inc_indent(xmlwriter *writer) @@ -969,7 +969,7 @@ static HRESULT write_output_attribute(xmlwriter *writer, const WCHAR *prefix, in return *hr;
write_output(writer, L" ", 1, hr); - write_output_qname(writer->output, prefix, prefix_len, local, local_len); + write_output_qname(writer, prefix, prefix_len, local, local_len, hr); write_output(writer, L"=", 1, hr); write_output_quoted(writer, value, -1, hr);
@@ -1448,13 +1448,13 @@ static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR pr
write_output(writer, L"<", 1, &hr); if (ns) - write_output_qname(writer->output, ns->prefix, ns->prefix_len, local_name, local_len); + write_output_qname(writer, ns->prefix, ns->prefix_len, local_name, local_len, &hr); else - write_output_qname(writer->output, prefix, prefix_len, local_name, local_len); + write_output_qname(writer, prefix, prefix_len, local_name, local_len, &hr);
if (!ns && (prefix_len || !is_empty_string(uri))) { - write_output_qname(writer->output, L" xmlns", 6, prefix, prefix_len); + write_output_qname(writer, L" xmlns", 6, prefix, prefix_len, &hr); write_output(writer, L"=", 1, &hr); write_output_buffer_quoted(writer->output, uri, -1); } @@ -1464,7 +1464,7 @@ static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR pr write_output(writer, L">", 1, &hr); write_output(writer, value, -1, &hr); write_output(writer, L"</", 2, &hr); - write_output_qname(writer->output, prefix, prefix_len, local_name, local_len); + write_output_qname(writer, prefix, prefix_len, local_name, local_len, &hr); write_output(writer, L">", 1, &hr); } else @@ -1483,7 +1483,7 @@ static HRESULT write_end_element(xmlwriter *writer, const struct element *elemen
if (writer->starttagopen) { - writer_output_ns(writer, element); + hr = writer_output_ns(writer, element); write_output(writer, L" />", 3, &hr); writer->starttagopen = 0; } @@ -2071,9 +2071,9 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
write_output_buffer_char(This->output, '<'); if (ns) - write_output_qname(This->output, ns->prefix, ns->prefix_len, local_name, local_len); + write_output_qname(This, ns->prefix, ns->prefix_len, local_name, local_len, &hr); else - write_output_qname(This->output, prefix, prefix_len, local_name, local_len); + write_output_qname(This, prefix, prefix_len, local_name, local_len, &hr); writer_inc_indent(This);
return S_OK;