Commit b56031c3 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msxml3: Implemented xmlnode_get_nodeTypedValue 'string' data type handling.

parent 41f061ea
......@@ -944,36 +944,62 @@ static HRESULT WINAPI xmlnode_get_definition(
return E_NOTIMPL;
}
static HRESULT WINAPI xmlnode_get_dataType(IXMLDOMNode*, VARIANT*);
inline HRESULT VARIANT_from_xmlChar(xmlChar *str, VARIANT *v, BSTR type)
{
if(!type || !lstrcmpiW(type, szString))
{
V_VT(v) = VT_BSTR;
V_BSTR(v) = bstr_from_xmlChar(str);
if(!V_BSTR(v))
return E_OUTOFMEMORY;
}
else
{
FIXME("Type handling not yet implemented\n");
V_VT(v) = VT_BSTR;
V_BSTR(v) = bstr_from_xmlChar(str);
if(!V_BSTR(v))
return E_OUTOFMEMORY;
}
return S_OK;
}
static HRESULT WINAPI xmlnode_get_nodeTypedValue(
IXMLDOMNode *iface,
VARIANT* typedValue)
{
xmlnode *This = impl_from_IXMLDOMNode( iface );
HRESULT r = S_FALSE;
VARIANT type;
xmlChar *content;
HRESULT hres = S_FALSE;
FIXME("ignoring data type %p %p\n", This, typedValue);
TRACE("iface %p\n", iface);
if(!typedValue)
return E_INVALIDARG;
V_VT(typedValue) = VT_NULL;
switch ( This->node->type )
{
case XML_ELEMENT_NODE:
{
xmlChar *content = xmlNodeGetContent(This->node);
V_VT(typedValue) = VT_BSTR;
V_BSTR(typedValue) = bstr_from_xmlChar( content );
xmlFree(content);
r = S_OK;
break;
}
default:
r = xmlnode_get_nodeValue(iface, typedValue);
}
if(This->node->type == XML_ELEMENT_NODE ||
This->node->type == XML_TEXT_NODE ||
This->node->type == XML_ENTITY_REF_NODE)
hres = xmlnode_get_dataType(iface, &type);
return r;
if(hres != S_OK && This->node->type != XML_ELEMENT_NODE)
return xmlnode_get_nodeValue(iface, typedValue);
content = xmlNodeGetContent(This->node);
hres = VARIANT_from_xmlChar(content, typedValue,
hres==S_OK ? V_BSTR(&type) : NULL);
xmlFree(content);
VariantClear(&type);
return hres;
}
static HRESULT WINAPI xmlnode_put_nodeTypedValue(
......
......@@ -147,8 +147,11 @@ static const CHAR szTransformOutput[] =
"</h1></body></html>";
static const CHAR szTypeValueXML[] =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<string>Wine</string>";
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
" <string>Wine</string>\n"
" <string2 dt:dt=\"string\">String</string2>\n"
"</root>";
static const CHAR szBasicTransformSSXMLPart1[] =
"<?xml version=\"1.0\"?>"
......@@ -3972,7 +3975,7 @@ static void test_NodeTypeValue(void)
hr = IXMLDOMDocument2_get_nodeTypedValue(doc, &v);
ok(hr == S_FALSE, "ret %08x\n", hr );
hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("string"), &pNode);
hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/string"), &pNode);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
......@@ -3987,11 +3990,25 @@ static void test_NodeTypeValue(void)
hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
ok(hr == S_OK, "ret %08x\n", hr );
ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
ok(!lstrcmpW( V_BSTR(&v), _bstr_("Wine") ), "incorrect value\n");
VariantClear( &v );
IXMLDOMNode_Release(pNode);
}
hr = IXMLDOMDocument2_selectSingleNode(doc, _bstr_("root/string2"), &pNode);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
hr = IXMLDOMNode_get_nodeTypedValue(pNode, &v);
ok(hr == S_OK, "ret %08x\n", hr );
ok(V_VT(&v) == VT_BSTR, "incorrect type\n");
ok(!lstrcmpW( V_BSTR(&v), _bstr_("String") ), "incorrect value\n");
VariantClear( &v );
IXMLDOMNode_Release(pNode);
}
}
IXMLDOMDocument2_Release(doc);
......
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