From 89f1bfabe3ed9fc7fccc1c413735e40de3a1d1bf Mon Sep 17 00:00:00 2001 From: Zhangrong Huang Date: Wed, 16 Jul 2008 20:13:18 +0800 Subject: [PATCH] msxml3: Add support for accessing document node. --- dlls/msxml3/domdoc.c | 14 ++++++++++++++ dlls/msxml3/msxml_private.h | 2 +- dlls/msxml3/node.c | 4 ++-- dlls/msxml3/tests/domdoc.c | 12 +----------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 59ea8c52328..3952b5e9e7c 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -2287,6 +2287,20 @@ HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj) return hr; } +IUnknown* create_domdoc( xmlNodePtr document ) +{ + HRESULT hr; + LPVOID pObj = NULL; + + TRACE("(%p)\n", document); + + hr = DOMDocument_create_from_xmldoc((xmlDocPtr)document, (IXMLDOMDocument2**)&pObj); + if (FAILED(hr)) + return NULL; + + return (IUnknown*)pObj; +} + #else HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj) diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index 34e480011cd..c365a11ab17 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -32,7 +32,7 @@ #endif /* constructors */ -extern IUnknown *create_domdoc( void ); +extern IUnknown *create_domdoc( xmlNodePtr document ); extern IUnknown *create_xmldoc( void ); extern IXMLDOMNode *create_node( xmlNodePtr node ); extern IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter ); diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 6b1d6b0b19b..8ace2eabf32 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -1450,8 +1450,8 @@ IXMLDOMNode *create_node( xmlNodePtr node ) pUnk = create_comment( node ); break; case XML_DOCUMENT_NODE: - ERR("shouldn't be here!\n"); - return NULL; + pUnk = create_domdoc( node ); + break; default: FIXME("only creating basic node for type %d\n", node->type); pUnk = create_basic_node( node, NULL ); diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 19a9a2ff0f0..7c64f6cd76d 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -330,8 +330,7 @@ static void node_to_string(IXMLDOMNode *node, char *buf) * results we "fix" it */ if (r == S_OK) ole_check(IXMLDOMNode_get_nodeType(new_node, &parent_type)); - /* we need also to workaround the no document node problem - see below */ - if (((r == S_FALSE && type != NODE_DOCUMENT) || parent_type == NODE_DOCUMENT) && type != NODE_PROCESSING_INSTRUCTION && pos==1) + if ((parent_type == NODE_DOCUMENT) && type != NODE_PROCESSING_INSTRUCTION && pos==1) { todo_wine ok(FALSE, "The first child of the document node in MSXML is the processing instruction\n"); pos++; @@ -347,15 +346,6 @@ static void node_to_string(IXMLDOMNode *node, char *buf) *(buf++) = '.'; } - /* currently we can't access document node in wine. All our examples this is the - * root node so to be able to test query results we add it */ - if (type != NODE_DOCUMENT) - { - todo_wine ok(FALSE, "Document node is not the last returned node!\n"); - *(buf++) = '.'; - *(buf++) = 'D'; - *(buf++) = '1'; - } *buf = 0; }