msxml3: Initial implementation of attributeDecl() in writer.

This commit is contained in:
Nikolay Sivov 2012-06-23 13:38:03 +04:00 committed by Alexandre Julliard
parent 7c9a1b52e3
commit d20e487717
2 changed files with 70 additions and 2 deletions

View File

@ -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,

View File

@ -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);