Commit 2a8552a9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Implement xmldecl-version property for a reader.

parent 240d1e4f
......@@ -209,6 +209,7 @@ typedef struct
BOOL isParsing;
struct bstrpool pool;
saxreader_feature features;
BSTR xmldecl_version;
MSXML_VERSION version;
} saxreader;
......@@ -334,6 +335,9 @@ static inline int saxreader_has_handler(const saxlocator *locator, enum saxhandl
static const WCHAR PropertyCharsetW[] = {
'c','h','a','r','s','e','t',0
};
static const WCHAR PropertyXmlDeclVersionW[] = {
'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
};
static const WCHAR PropertyDeclHandlerW[] = {
'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
......@@ -1311,6 +1315,13 @@ static void libxmlStartDocument(void *ctx)
This->column++;
}
/* store version value, declaration has to contain version attribute */
if (This->pParserCtxt->standalone != -1)
{
SysFreeString(This->saxreader->xmldecl_version);
This->saxreader->xmldecl_version = bstr_from_xmlChar(This->pParserCtxt->version);
}
if (saxreader_has_handler(This, SAXContentHandler))
{
if(This->vbInterface)
......@@ -2654,6 +2665,13 @@ static HRESULT internal_getProperty(const saxreader* This, const WCHAR *prop, VA
return S_OK;
}
if (!memcmp(PropertyXmlDeclVersionW, prop, sizeof(PropertyXmlDeclVersionW)))
{
V_VT(value) = VT_BSTR;
V_BSTR(value) = SysAllocString(This->xmldecl_version);
return S_OK;
}
FIXME("(%p)->(%s) unsupported property\n", This, debugstr_w(prop));
return E_NOTIMPL;
......@@ -2725,6 +2743,7 @@ static ULONG WINAPI saxxmlreader_Release(
IUnknown_Release(iface->vbhandler);
}
SysFreeString(This->xmldecl_version);
free_bstr_pool(&This->pool);
release_dispex(&This->dispex);
......@@ -3214,6 +3233,7 @@ HRESULT SAXXMLReader_create(MSXML_VERSION version, IUnknown *outer, LPVOID *ppOb
reader->ref = 1;
memset(reader->saxhandlers, 0, sizeof(reader->saxhandlers));
reader->isParsing = FALSE;
reader->xmldecl_version = NULL;
reader->pool.pool = NULL;
reader->pool.index = 0;
reader->pool.len = 0;
......
......@@ -557,7 +557,7 @@ static const CHAR szUtf8XML[] =
static const char utf8xml2[] =
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\r\n";
static const CHAR testXML[] =
static const char testXML[] =
"<?xml version=\"1.0\" ?>\n"
"<BankAccount>\n"
" <Number>1234</Number>\n"
......@@ -2247,6 +2247,7 @@ static void test_saxreader_properties(void)
const struct saxreader_props_test_t *ptr = props_test_data;
ISAXXMLReader *reader;
HRESULT hr;
VARIANT v;
hr = CoCreateInstance(&CLSID_SAXXMLReader, NULL, CLSCTX_INPROC_SERVER,
&IID_ISAXXMLReader, (void**)&reader);
......@@ -2257,7 +2258,6 @@ static void test_saxreader_properties(void)
while (ptr->prop_name)
{
VARIANT v;
LONG ref;
init_saxlexicalhandler(&lexicalhandler, S_OK);
......@@ -2356,9 +2356,54 @@ static void test_saxreader_properties(void)
ok(V_UNKNOWN(&v) != NULL, "got %p\n", V_UNKNOWN(&v));
ptr++;
free_bstrs();
}
ISAXXMLReader_Release(reader);
if (!is_clsid_supported(&CLSID_SAXXMLReader40, reader_support_data))
return;
hr = CoCreateInstance(&CLSID_SAXXMLReader40, NULL, CLSCTX_INPROC_SERVER,
&IID_ISAXXMLReader, (void**)&reader);
EXPECT_HR(hr, S_OK);
/* xmldecl-version property */
V_VT(&v) = VT_EMPTY;
V_BSTR(&v) = (void*)0xdeadbeef;
hr = ISAXXMLReader_getProperty(reader, _bstr_("xmldecl-version"), &v);
EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(V_BSTR(&v) == NULL, "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
/* stream without declaration */
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = _bstr_("<element></element>");
hr = ISAXXMLReader_parse(reader, v);
EXPECT_HR(hr, S_OK);
V_VT(&v) = VT_EMPTY;
V_BSTR(&v) = (void*)0xdeadbeef;
hr = ISAXXMLReader_getProperty(reader, _bstr_("xmldecl-version"), &v);
EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(V_BSTR(&v) == NULL, "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
/* stream with declaration */
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = _bstr_("<?xml version=\"1.0\"?><element></element>");
hr = ISAXXMLReader_parse(reader, v);
EXPECT_HR(hr, S_OK);
V_VT(&v) = VT_EMPTY;
V_BSTR(&v) = (void*)0xdeadbeef;
hr = ISAXXMLReader_getProperty(reader, _bstr_("xmldecl-version"), &v);
EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(!lstrcmpW(V_BSTR(&v), _bstr_("1.0")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
ISAXXMLReader_Release(reader);
free_bstrs();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment