Implements or at least tries to implement:
WriteName
WriteQualifiedName
WriteNmToken
WriteEntityRef
Signed-off-by: David Kahurani k.kahurani@gmail.com
-- v2: xmllite/writer: Implement WriteQualifiedName. xmllite/writer: Implement WriteNmToken. xmllite/writer: Implement WriteEntityRef. xmllite/writer: Implement WriteName.
From: David Kahurani k.kahurani@gmail.com
Writes a qualified name to output after validating it.
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/xmllite/tests/writer.c | 98 +++++++++++++++++++++++++++++++++++++ dlls/xmllite/writer.c | 31 +++++++++--- 2 files changed, 123 insertions(+), 6 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 572b3a9fd67..90226b2eb4d 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1785,6 +1785,103 @@ static void test_WriteAttributeString(void) IXmlWriter_Release(writer); }
+static void test_WriteName(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, L""); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, L"name"); + ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteName(writer, L"name"); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, L"a:a:a"); + ok(hr == WC_E_NAMECHARACTER, "Unexpcted hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"root", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, L"name"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteFullEndElement(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, L"ab:name"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<root><a>name</a><b>ab:name</b></root>"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteName(writer, L""); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a"); + + IStream_Release(stream); + IXmlWriter_Release(writer); +} + static void test_WriteFullEndElement(void) { IXmlWriter *writer; @@ -2971,4 +3068,5 @@ START_TEST(writer) test_WriteAttributes(); test_WriteNode(); test_WriteNodeShallow(); + test_WriteName(); } diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 128d666e82c..f4d1a474232 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1541,27 +1541,46 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface) return S_OK; }
-static HRESULT WINAPI xmlwriter_WriteName(IXmlWriter *iface, LPCWSTR pwszName) +static HRESULT WINAPI xmlwriter_WriteName(IXmlWriter *iface, LPCWSTR qname) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + const WCHAR *p = qname;
- FIXME("%p %s\n", This, wine_dbgstr_w(pwszName)); + TRACE("%p %s\n", iface, wine_dbgstr_w(qname));
- switch (This->state) + if (is_empty_string(qname)) + return E_INVALIDARG; + + while (*p && is_ncnamechar(*p)) + p++; + + if (*p && *p++ == ':') + { + while (*p && is_ncnamechar(*p)) + p++; + } + + if (*p) return WC_E_NAMECHARACTER; + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_Ready: case XmlWriterState_DocClosed: - This->state = XmlWriterState_DocClosed; + writer->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; + case XmlWriterState_ElemStarted: + writer_close_starttag(writer); + break; default: ; }
- return E_NOTIMPL; + write_output_buffer(writer->output, qname, p - qname); + return S_OK; }
static HRESULT WINAPI xmlwriter_WriteNmToken(IXmlWriter *iface, LPCWSTR pwszNmToken)
From: David Kahurani k.kahurani@gmail.com
Validate a name then write it.
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/xmllite/tests/writer.c | 77 ++++++++++++++++++++++++++++++++++++- dlls/xmllite/writer.c | 33 +++++++++++++--- 2 files changed, 104 insertions(+), 6 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 90226b2eb4d..7896392cafb 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1842,7 +1842,7 @@ static void test_WriteName(void) hr = IXmlWriter_WriteName(writer, L"name"); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- hr = IXmlWriter_WriteFullEndElement(writer); + hr = IXmlWriter_WriteEndElement(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", NULL); @@ -1882,6 +1882,80 @@ static void test_WriteName(void) IXmlWriter_Release(writer); }
+static void test_WriteEntityRef(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, L""); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, L"name"); + ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteEntityRef(writer, L"name"); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, L"na:me"); + ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, L"name"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, L".name"); + ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEntityRef(writer, L"name"); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a>&name;</a>"); + + IStream_Release(stream); + IXmlWriter_Release(writer); +} + static void test_WriteFullEndElement(void) { IXmlWriter *writer; @@ -3069,4 +3143,5 @@ START_TEST(writer) test_WriteNode(); test_WriteNodeShallow(); test_WriteName(); + test_WriteEntityRef(); } diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index f4d1a474232..5696e09782b 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1471,25 +1471,48 @@ static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface) return S_OK; }
-static HRESULT WINAPI xmlwriter_WriteEntityRef(IXmlWriter *iface, LPCWSTR pwszName) +static HRESULT WINAPI xmlwriter_WriteEntityRef(IXmlWriter *iface, LPCWSTR name) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + const WCHAR *p = name;
- FIXME("%p %s\n", This, wine_dbgstr_w(pwszName)); + TRACE("%p %s\n", iface, wine_dbgstr_w(name));
- switch (This->state) + if (is_empty_string(name)) + return E_INVALIDARG; + + if (!is_namestartchar(*p++)) + return WC_E_NAMECHARACTER; + + while (*p) + { + if (!is_ncnamechar(*p)) + return WC_E_NAMECHARACTER; + p++; + } + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; case XmlWriterState_DocClosed: + case XmlWriterState_Ready: + writer->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_ElemStarted: + writer_close_starttag(writer); + break; default: ; }
- return E_NOTIMPL; + write_output_buffer_char(writer->output, '&'); + write_output_buffer(writer->output, name, -1); + write_output_buffer_char(writer->output, ';'); + + return S_OK; }
static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface)
From: David Kahurani k.kahurani@gmail.com
Validate and write a NmToken. --- dlls/xmllite/tests/writer.c | 72 +++++++++++++++++++++++++++++++++++++ dlls/xmllite/writer.c | 30 ++++++++++++---- 2 files changed, 96 insertions(+), 6 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 7896392cafb..3a44af1c063 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -1956,6 +1956,77 @@ static void test_WriteEntityRef(void) IXmlWriter_Release(writer); }
+static void test_WriteNmToken(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, L"token"); + ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, L""); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteNmToken(writer, L"token"); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + IStream_Release(stream); + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, L"na@me"); + ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, L"na:me:x"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteNmToken(writer, L"name"); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a>na:me:x</a>"); + + IStream_Release(stream); + IXmlWriter_Release(writer); +} + static void test_WriteFullEndElement(void) { IXmlWriter *writer; @@ -3144,4 +3215,5 @@ START_TEST(writer) test_WriteNodeShallow(); test_WriteName(); test_WriteEntityRef(); + test_WriteNmToken(); } diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 5696e09782b..bb52b380ce5 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1606,27 +1606,45 @@ static HRESULT WINAPI xmlwriter_WriteName(IXmlWriter *iface, LPCWSTR qname) return S_OK; }
-static HRESULT WINAPI xmlwriter_WriteNmToken(IXmlWriter *iface, LPCWSTR pwszNmToken) +static HRESULT WINAPI xmlwriter_WriteNmToken(IXmlWriter *iface, LPCWSTR token) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + const WCHAR *p = token; + int count = 0;
- FIXME("%p %s\n", This, wine_dbgstr_w(pwszNmToken)); + TRACE("%p %s\n", iface, wine_dbgstr_w(token));
- switch (This->state) + if (is_empty_string(token)) + return E_INVALIDARG; + + while (*p) + { + if (!is_namechar(*p)) + return WC_E_NAMECHARACTER; + + p++; + count++; + } + + switch (writer->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_Ready: case XmlWriterState_DocClosed: - This->state = XmlWriterState_DocClosed; + writer->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; + case XmlWriterState_ElemStarted: + writer_close_starttag(writer); + break; default: ; }
- return E_NOTIMPL; + write_output_buffer(writer->output, token, count); + return S_OK; }
static HRESULT writer_write_node(IXmlWriter *writer, IXmlReader *reader, BOOL shallow, BOOL write_default_attributes)
From: David Kahurani k.kahurani@gmail.com
Validate a name, associate it with a prefix, if present thereof and write the qualified name to the out
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/xmllite/tests/writer.c | 122 ++++++++++++++++++++++++++++++++++++ dlls/xmllite/writer.c | 36 +++++++++-- 2 files changed, 152 insertions(+), 6 deletions(-)
diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 3a44af1c063..1185fc34101 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -2027,6 +2027,127 @@ static void test_WriteNmToken(void) IXmlWriter_Release(writer); }
+static void test_WriteQualifiedName(void) +{ + IXmlWriter *writer; + IStream *stream; + HRESULT hr; + + hr = CreateXmlWriter(&IID_IXmlWriter, (void**)&writer, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"", L"cd"); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, NULL, L"cd"); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"xyz@xyz"); + ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"ab", NULL); + ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"cd"); + ok(hr == E_UNEXPECTED, "Unexpected hr %#lx.\n", hr); + + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"cd"); + ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, L"ab", L"a", L"cd"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"a@b", L"cd"); + ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<ab:a"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, L"ab", L"a", L"cd"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"ab", L"de"); + 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(stream, + "<ab:a xmlns:ab="cd">"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + writer_set_property(writer, XmlWriterProperty_OmitXmlDeclaration); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"a", L"cd"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, NULL, L"b", L"gh"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"xy", L"cd"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<a xmlns="cd"><b xmlns="gh">xy</b></a>"); + + IStream_Release(stream); + stream = writer_set_output(writer); + + hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Omit); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, L"ab", L"a", L"cd"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteStartElement(writer, L"ef", L"b", L"gh"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteQualifiedName(writer, L"xy", L"cd"); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_WriteEndDocument(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IXmlWriter_Flush(writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + CHECK_OUTPUT(stream, + "<ab:a xmlns:ab="cd"><ef:b xmlns:ef="gh">ab:xy</ef:b></ab:a>"); + + IStream_Release(stream); + IXmlWriter_Release(writer); +} + static void test_WriteFullEndElement(void) { IXmlWriter *writer; @@ -3216,4 +3337,5 @@ START_TEST(writer) test_WriteName(); test_WriteEntityRef(); test_WriteNmToken(); + test_WriteQualifiedName(); } diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index bb52b380ce5..d6f93d1c2dd 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1804,26 +1804,50 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP return S_OK; }
-static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, LPCWSTR pwszLocalName, - LPCWSTR pwszNamespaceUri) +static HRESULT WINAPI xmlwriter_WriteQualifiedName(IXmlWriter *iface, LPCWSTR local, + LPCWSTR uri) { - xmlwriter *This = impl_from_IXmlWriter(iface); + xmlwriter *writer = impl_from_IXmlWriter(iface); + struct ns *ns; + int local_len;
- FIXME("%p %s %s\n", This, wine_dbgstr_w(pwszLocalName), wine_dbgstr_w(pwszNamespaceUri)); + TRACE("%p %s %s\n", iface, wine_dbgstr_w(local), wine_dbgstr_w(uri));
- switch (This->state) + if (is_empty_string(local)) + return E_INVALIDARG; + + if (is_valid_ncname(local, &local_len)) + return WC_E_NAMECHARACTER; + + 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: + writer_close_starttag(writer); + break; default: ; }
- return E_NOTIMPL; + ns = writer_find_ns(writer, NULL, uri); + + if (!ns) + return WR_E_NAMESPACEUNDECLARED; + + if (ns->prefix) + { + write_output_buffer(writer->output, ns->prefix, ns->prefix_len); + write_output_buffer_char(writer->output, ':'); + } + + write_output_buffer(writer->output, local, local_len); + return S_OK; }
static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)
Hello,
It has been a while since this but I do wonder whether it is possible to get this merged. Preferably as is
It might not be perfect but afterall, it is better than none.
On Mon Mar 11 08:53:39 2024 +0000, David Kahurani wrote:
Hello, It has been a while since this but I do wonder whether it is possible to get this merged. Preferably as is It might not be perfect but afterall, it is better than none.
Were the previous comments addressed in full?