xmllite: Support reporting of a local name and value for attributes.
This commit is contained in:
parent
36d999527b
commit
e51ab3c03a
|
@ -226,6 +226,7 @@ struct element
|
|||
{
|
||||
struct list entry;
|
||||
strval qname;
|
||||
strval localname;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -437,7 +438,7 @@ static void reader_dec_depth(xmlreader *reader)
|
|||
if (reader->depth > 1) reader->depth--;
|
||||
}
|
||||
|
||||
static HRESULT reader_push_element(xmlreader *reader, strval *qname)
|
||||
static HRESULT reader_push_element(xmlreader *reader, strval *qname, strval *localname)
|
||||
{
|
||||
struct element *elem;
|
||||
HRESULT hr;
|
||||
|
@ -451,6 +452,14 @@ static HRESULT reader_push_element(xmlreader *reader, strval *qname)
|
|||
return hr;
|
||||
}
|
||||
|
||||
hr = reader_strvaldup(reader, localname, &elem->localname);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
reader_free_strvalued(reader, &elem->qname);
|
||||
reader_free(reader, elem);
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (!list_empty(&reader->elements))
|
||||
{
|
||||
hr = reader_inc_depth(reader);
|
||||
|
@ -473,6 +482,7 @@ static void reader_pop_element(xmlreader *reader)
|
|||
{
|
||||
list_remove(&elem->entry);
|
||||
reader_free_strvalued(reader, &elem->qname);
|
||||
reader_free_strvalued(reader, &elem->localname);
|
||||
reader_free(reader, elem);
|
||||
reader_dec_depth(reader);
|
||||
}
|
||||
|
@ -1524,8 +1534,7 @@ static HRESULT reader_parse_sys_literal(xmlreader *reader, strval *literal)
|
|||
}
|
||||
if (*cur == quote) reader_skipn(reader, 1);
|
||||
|
||||
literal->str = start;
|
||||
literal->len = cur-start;
|
||||
reader_init_strvalue(start, cur-start, literal);
|
||||
TRACE("%s\n", debugstr_wn(start, cur-start));
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -1872,7 +1881,7 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca
|
|||
{
|
||||
/* skip '>' */
|
||||
reader_skipn(reader, 1);
|
||||
return reader_push_element(reader, qname);
|
||||
return reader_push_element(reader, qname, local);
|
||||
}
|
||||
|
||||
hr = reader_parse_attribute(reader);
|
||||
|
@ -2413,6 +2422,9 @@ static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface)
|
|||
|
||||
if (!This->attr_count) return S_FALSE;
|
||||
This->attr = LIST_ENTRY(list_head(&This->attrs), struct attribute, entry);
|
||||
reader_set_strvalue(This, StringValue_LocalName, &This->attr->localname);
|
||||
reader_set_strvalue(This, StringValue_Value, &This->attr->value);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -2430,7 +2442,11 @@ static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface)
|
|||
|
||||
next = list_next(&This->attrs, &This->attr->entry);
|
||||
if (next)
|
||||
{
|
||||
This->attr = LIST_ENTRY(next, struct attribute, entry);
|
||||
reader_set_strvalue(This, StringValue_LocalName, &This->attr->localname);
|
||||
reader_set_strvalue(This, StringValue_Value, &This->attr->value);
|
||||
}
|
||||
|
||||
return next ? S_OK : S_FALSE;
|
||||
}
|
||||
|
@ -2446,11 +2462,21 @@ static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
|
|||
static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
|
||||
{
|
||||
xmlreader *This = impl_from_IXmlReader(iface);
|
||||
struct element *elem;
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
if (!This->attr_count) return S_FALSE;
|
||||
This->attr = NULL;
|
||||
|
||||
/* FIXME: support other node types with 'attributes' like DTD */
|
||||
elem = LIST_ENTRY(list_head(&This->elements), struct element, entry);
|
||||
if (elem)
|
||||
{
|
||||
reader_set_strvalue(This, StringValue_QualifiedName, &elem->qname);
|
||||
reader_set_strvalue(This, StringValue_LocalName, &elem->localname);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1048,18 +1048,16 @@ static void test_read_dtd(void)
|
|||
str = NULL;
|
||||
hr = IXmlReader_GetLocalName(reader, &str, &len);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
todo_wine {
|
||||
ok(len == lstrlenW(sysW), "got %u\n", len);
|
||||
ok(!lstrcmpW(str, sysW), "got %s\n", wine_dbgstr_w(str));
|
||||
}
|
||||
|
||||
len = 0;
|
||||
str = NULL;
|
||||
hr = IXmlReader_GetValue(reader, &str, &len);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
todo_wine {
|
||||
ok(len == lstrlenW(sysvalW), "got %u\n", len);
|
||||
ok(!lstrcmpW(str, sysvalW), "got %s\n", wine_dbgstr_w(str));
|
||||
}
|
||||
|
||||
hr = IXmlReader_MoveToElement(reader);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
|
@ -1067,9 +1065,10 @@ todo_wine {
|
|||
str = NULL;
|
||||
hr = IXmlReader_GetLocalName(reader, &str, &len);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
todo_wine {
|
||||
ok(len == lstrlenW(dtdnameW), "got %u\n", len);
|
||||
ok(!lstrcmpW(str, dtdnameW), "got %s\n", wine_dbgstr_w(str));
|
||||
|
||||
}
|
||||
len = 0;
|
||||
str = NULL;
|
||||
hr = IXmlReader_GetQualifiedName(reader, &str, &len);
|
||||
|
@ -1617,12 +1616,11 @@ static void test_read_attribute(void)
|
|||
str = NULL;
|
||||
hr = IXmlReader_GetLocalName(reader, &str, &len);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
todo_wine {
|
||||
ok(len == strlen(test->name), "got %u\n", len);
|
||||
str_exp = a2w(test->name);
|
||||
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
|
||||
free_str(str_exp);
|
||||
}
|
||||
|
||||
len = 1;
|
||||
str = NULL;
|
||||
hr = IXmlReader_GetQualifiedName(reader, &str, &len);
|
||||
|
@ -1638,13 +1636,11 @@ static void test_read_attribute(void)
|
|||
str = NULL;
|
||||
hr = IXmlReader_GetValue(reader, &str, &len);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
todo_wine {
|
||||
ok(len == strlen(test->value), "got %u\n", len);
|
||||
str_exp = a2w(test->value);
|
||||
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
|
||||
free_str(str_exp);
|
||||
}
|
||||
}
|
||||
|
||||
IStream_Release(stream);
|
||||
test++;
|
||||
|
|
Loading…
Reference in New Issue