[4/5] msxml3: Initial implementation of attributeDecl() in writer
Nikolay Sivov
nsivov at codeweavers.com
Mon Jun 25 02:49:04 CDT 2012
Initial implementation of attributeDecl() in writer
-------------- next part --------------
>From 22480248c49f9c282be71acd5fffc5e268f9ff86 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat, 23 Jun 2012 13:38:03 +0400
Subject: [PATCH 04/10] Initial implementation of attributeDecl() in writer
---
dlls/msxml3/mxwriter.c | 34 ++++++++++++++++++++++++++++++++--
dlls/msxml3/tests/saxreader.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index daa6db8..b9989b2 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -1481,10 +1481,40 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface,
const WCHAR *value, int n_value)
{
mxwriter *This = impl_from_ISAXDeclHandler( iface );
- FIXME("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d): stub\n", This, debugstr_wn(element, n_element), n_element,
+ static const WCHAR attlistW[] = {'<','!','A','T','T','L','I','S','T',' '};
+ static const WCHAR closeelementW[] = {'>','\r','\n'};
+
+ TRACE("(%p)->(%s:%d %s:%d %s:%d %s:%d %s:%d)\n", This, debugstr_wn(element, n_element), n_element,
debugstr_wn(attr, n_attr), n_attr, debugstr_wn(type, n_type), n_type, debugstr_wn(Default, n_default), n_default,
debugstr_wn(value, n_value), n_value);
- return E_NOTIMPL;
+
+ write_output_buffer(This->buffer, attlistW, sizeof(attlistW)/sizeof(WCHAR));
+ if (n_element) {
+ write_output_buffer(This->buffer, element, n_element);
+ write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR));
+ }
+
+ if (n_attr) {
+ write_output_buffer(This->buffer, attr, n_attr);
+ write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR));
+ }
+
+ if (n_type) {
+ write_output_buffer(This->buffer, type, n_type);
+ write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR));
+ }
+
+ if (n_default) {
+ write_output_buffer(This->buffer, Default, n_default);
+ write_output_buffer(This->buffer, spaceW, sizeof(spaceW)/sizeof(WCHAR));
+ }
+
+ if (n_value)
+ write_output_buffer_quoted(This->buffer, value, n_value);
+
+ write_output_buffer(This->buffer, closeelementW, sizeof(closeelementW)/sizeof(WCHAR));
+
+ return S_OK;
}
static HRESULT WINAPI SAXDeclHandler_internalEntityDecl(ISAXDeclHandler *iface,
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index be96716..5efe44e 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -4450,6 +4450,44 @@ static void test_mxwriter_dtd(void)
V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
+ /* attribute declaration */
+ V_VT(&dest) = VT_EMPTY;
+ hr = IMXWriter_put_output(writer, dest);
+ EXPECT_HR(hr, S_OK);
+
+ hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element"), strlen("element"),
+ _bstr_("attribute"), strlen("attribute"), _bstr_("CDATA"), strlen("CDATA"),
+ _bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value"), strlen("value"));
+ EXPECT_HR(hr, S_OK);
+
+ V_VT(&dest) = VT_EMPTY;
+ hr = IMXWriter_get_output(writer, &dest);
+ EXPECT_HR(hr, S_OK);
+ ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
+ ok(!lstrcmpW(_bstr_("<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n"),
+ V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
+ VariantClear(&dest);
+
+ hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element"), strlen("element"),
+ _bstr_("attribute2"), strlen("attribute2"), _bstr_("CDATA"), strlen("CDATA"),
+ _bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value2"), strlen("value2"));
+ EXPECT_HR(hr, S_OK);
+
+ hr = ISAXDeclHandler_attributeDecl(decl, _bstr_("element2"), strlen("element2"),
+ _bstr_("attribute3"), strlen("attribute3"), _bstr_("CDATA"), strlen("CDATA"),
+ _bstr_("#REQUIRED"), strlen("#REQUIRED"), _bstr_("value3"), strlen("value3"));
+ EXPECT_HR(hr, S_OK);
+
+ V_VT(&dest) = VT_EMPTY;
+ hr = IMXWriter_get_output(writer, &dest);
+ EXPECT_HR(hr, S_OK);
+ ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest));
+ ok(!lstrcmpW(_bstr_("<!ATTLIST element attribute CDATA #REQUIRED \"value\">\r\n"
+ "<!ATTLIST element attribute2 CDATA #REQUIRED \"value2\">\r\n"
+ "<!ATTLIST element2 attribute3 CDATA #REQUIRED \"value3\">\r\n"),
+ V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
+ VariantClear(&dest);
+
ISAXContentHandler_Release(content);
ISAXLexicalHandler_Release(lexical);
ISAXDeclHandler_Release(decl);
--
1.5.6.5
More information about the wine-patches
mailing list