Commit 4460cb33 authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

msxml3: Treat namespaces as floating attributes.

parent 27980430
...@@ -1754,8 +1754,11 @@ static HRESULT domelem_remove_named_item(xmlNodePtr node, BSTR name, IXMLDOMNode ...@@ -1754,8 +1754,11 @@ static HRESULT domelem_remove_named_item(xmlNodePtr node, BSTR name, IXMLDOMNode
static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode **item) static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode **item)
{ {
xmlNsPtr ns, xmlns;
xmlAttrPtr curr; xmlAttrPtr curr;
LONG attrIndex; LONG attrIndex;
IUnknown *unk;
HRESULT hr;
TRACE("(%p)->(%d %p)\n", node, index, item); TRACE("(%p)->(%d %p)\n", node, index, item);
...@@ -1764,42 +1767,75 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode * ...@@ -1764,42 +1767,75 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode *
if (index < 0) if (index < 0)
return S_FALSE; return S_FALSE;
attrIndex = 0;
curr = node->properties; curr = node->properties;
if (curr) {
for (attrIndex = 0; attrIndex < index; attrIndex++) { for (; attrIndex < index && curr->next != NULL; attrIndex++)
if (curr->next == NULL)
return S_FALSE;
else
curr = curr->next; curr = curr->next;
if (attrIndex == index) {
*item = create_node( (xmlNodePtr) curr );
return S_OK;
}
} }
*item = create_node( (xmlNodePtr) curr ); if (!node->nsDef)
return S_FALSE;
return S_OK; attrIndex++;
ns = node->nsDef;
for (; attrIndex < index && ns->next != NULL; attrIndex++)
ns = ns->next;
if (attrIndex < index)
return S_FALSE;
xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns");
if (!xmlns)
return E_OUTOFMEMORY;
curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href);
if (!curr) {
xmlFreeNs(xmlns);
return E_OUTOFMEMORY;
}
curr->doc = node->doc;
unk = create_attribute((xmlNodePtr)curr, TRUE);
if (!unk) {
xmlFreeNs(xmlns);
xmlFreeProp(curr);
return E_OUTOFMEMORY;
}
hr = IUnknown_QueryInterface(unk, &IID_IXMLDOMNode, (void**)item);
IUnknown_Release(unk);
return hr;
} }
static HRESULT domelem_get_length(const xmlNodePtr node, LONG *length) static HRESULT domelem_get_length(const xmlNodePtr node, LONG *length)
{ {
xmlAttrPtr first;
xmlAttrPtr curr; xmlAttrPtr curr;
LONG attrCount; LONG attrCount;
xmlNsPtr ns;
TRACE("(%p)->(%p)\n", node, length); TRACE("(%p)->(%p)\n", node, length);
if( !length ) if( !length )
return E_INVALIDARG; return E_INVALIDARG;
first = node->properties; attrCount = 0;
if (first == NULL) { curr = node->properties;
*length = 0; while (curr) {
return S_OK; attrCount++;
curr = curr->next;
} }
curr = first; ns = node->nsDef;
attrCount = 1; while (ns) {
while (curr->next) {
attrCount++; attrCount++;
curr = curr->next; ns = ns->next;
} }
*length = attrCount; *length = attrCount;
......
...@@ -12891,7 +12891,7 @@ static void test_namespaces_as_attributes(void) ...@@ -12891,7 +12891,7 @@ static void test_namespaces_as_attributes(void)
len = -1; len = -1;
hr = IXMLDOMNamedNodeMap_get_length(map, &len); hr = IXMLDOMNamedNodeMap_get_length(map, &len);
ok(SUCCEEDED(hr), "Failed to get map length, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to get map length, hr %#x.\n", hr);
todo_wine ok(len == 3, "got %d\n", len); ok(len == 3, "got %d\n", len);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
......
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