xmllite/reader: Return qualified element names from the stack, instead of input buffer.

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-08 07:07:11 +03:00 committed by Alexandre Julliard
parent 3ae1043fc1
commit b57589a32d
2 changed files with 42 additions and 6 deletions

View File

@ -2284,7 +2284,6 @@ static HRESULT reader_parse_endtag(xmlreader *reader)
reader->nodetype = XmlNodeType_EndElement;
reader->is_empty_element = FALSE;
reader_set_strvalue(reader, StringValue_Prefix, &prefix);
reader_set_strvalue(reader, StringValue_QualifiedName, &qname);
return S_OK;
}
@ -2913,10 +2912,35 @@ static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *name, UINT *len)
{
xmlreader *This = impl_from_IXmlReader(iface);
XmlNodeType nodetype;
UINT length;
TRACE("(%p)->(%p %p)\n", This, name, len);
*name = This->strvalues[StringValue_QualifiedName].str;
if (len) *len = This->strvalues[StringValue_QualifiedName].len;
if (!len)
len = &length;
switch ((nodetype = reader_get_nodetype(This)))
{
case XmlNodeType_Element:
case XmlNodeType_EndElement:
/* empty elements are not added to the stack */
if (!This->is_empty_element)
{
struct element *element;
element = LIST_ENTRY(list_head(&This->elements), struct element, entry);
*name = element->qname.str;
*len = element->qname.len;
break;
}
/* fallthrough */
default:
*name = This->strvalues[StringValue_QualifiedName].str;
*len = This->strvalues[StringValue_QualifiedName].len;
break;
}
return S_OK;
}

View File

@ -2146,9 +2146,9 @@ static void test_namespaceuri(void)
type = ~0u;
while (IXmlReader_Read(reader, &type) == S_OK) {
const WCHAR *uri, *local;
const WCHAR *uri, *local, *qname;
UINT length, length2;
WCHAR *uriW;
UINT length;
ok(type == XmlNodeType_Element ||
type == XmlNodeType_Text ||
@ -2165,10 +2165,22 @@ static void test_namespaceuri(void)
ok(hr == S_OK, "S_OK, got %08x\n", hr);
ok(local != NULL, "Unexpected NULL local name pointer\n");
if (type == XmlNodeType_Element || type == XmlNodeType_EndElement)
qname = NULL;
length2 = 0;
hr = IXmlReader_GetQualifiedName(reader, &qname, &length2);
ok(hr == S_OK, "S_OK, got %08x\n", hr);
ok(qname != NULL, "Unexpected NULL qualified name pointer\n");
if (type == XmlNodeType_Element ||
type == XmlNodeType_EndElement ||
type == XmlNodeType_ProcessingInstruction ||
type == XmlNodeType_XmlDeclaration)
{
ok(*local != 0, "Unexpected empty local name\n");
ok(length > 0, "Unexpected local name length\n");
ok(*qname != 0, "Unexpected empty qualified name\n");
ok(length2 > 0, "Unexpected qualified name length\n");
}
uri = NULL;