xmllite/reader: Return prefixes from namespace stack.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-03-09 07:14:06 +03:00 committed by Alexandre Julliard
parent 348fcb18af
commit d3319f60ad
2 changed files with 43 additions and 4 deletions

View File

@ -3087,13 +3087,51 @@ static HRESULT WINAPI xmlreader_GetLocalName(IXmlReader* iface, LPCWSTR *name, U
return S_OK;
}
static HRESULT WINAPI xmlreader_GetPrefix(IXmlReader* iface, LPCWSTR *prefix, UINT *len)
static HRESULT WINAPI xmlreader_GetPrefix(IXmlReader* iface, const WCHAR **ret, UINT *len)
{
xmlreader *This = impl_from_IXmlReader(iface);
XmlNodeType nodetype;
UINT length;
TRACE("(%p)->(%p %p)\n", This, ret, len);
if (!len)
len = &length;
*ret = emptyW;
*len = 0;
switch ((nodetype = reader_get_nodetype(This)))
{
case XmlNodeType_Element:
case XmlNodeType_EndElement:
case XmlNodeType_Attribute:
{
const strval *prefix = &This->strvalues[StringValue_Prefix];
struct ns *ns;
if (strval_eq(This, prefix, &strval_xml))
{
*ret = xmlW;
*len = 3;
}
else if (strval_eq(This, prefix, &strval_xmlns))
{
*ret = xmlnsW;
*len = 5;
}
else if ((ns = reader_lookup_ns(This, prefix)))
{
*ret = ns->prefix.str;
*len = ns->prefix.len;
}
break;
}
default:
;
}
TRACE("(%p)->(%p %p)\n", This, prefix, len);
*prefix = This->strvalues[StringValue_Prefix].str;
if (len) *len = This->strvalues[StringValue_Prefix].len;
return S_OK;
}

View File

@ -2024,6 +2024,7 @@ static void test_prefix(void)
} prefix_tests[] =
{
{ "<b xmlns=\"defns\" xml:a=\"a ns\"/>", "", "", "xml" },
{ "<c:b xmlns:c=\"c ns\" xml:a=\"a ns\"/>", "c", "xmlns", "xml" },
};
IXmlReader *reader;
unsigned int i;