Commit b9e9e041 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msxml3: Implemented IXMLDOMCDATASection COM Object.

parent bf4a43e1
......@@ -10,6 +10,7 @@ EXTRAINCL = @XML2INCL@ @XSLTINCL@
C_SRCS = \
attribute.c \
cdata.c \
comment.c \
domdoc.c \
element.c \
......
......@@ -947,8 +947,29 @@ static HRESULT WINAPI domdoc_createCDATASection(
BSTR data,
IXMLDOMCDATASection** cdata )
{
FIXME("\n");
return E_NOTIMPL;
domdoc *This = impl_from_IXMLDOMDocument2( iface );
xmlNodePtr xmlnode;
xmlChar *xml_content;
TRACE("%p->(%s %p)\n", iface, debugstr_w(data), comment);
if(!cdata)
return E_INVALIDARG;
*cdata = NULL;
xml_content = xmlChar_from_wchar((WCHAR*)data);
xmlnode = xmlNewCDataBlock(get_doc( This ), xml_content, strlen( (char*)xml_content) );
HeapFree(GetProcessHeap(), 0, xml_content);
if(!xmlnode)
return E_FAIL;
xmlnode->doc = get_doc( This );
*cdata = (IXMLDOMCDATASection*)create_cdata(xmlnode);
return S_OK;
}
......
......@@ -41,6 +41,7 @@ extern IUnknown *create_attribute( xmlNodePtr attribute );
extern IUnknown *create_text( xmlNodePtr text );
extern IUnknown *create_pi( xmlNodePtr pi );
extern IUnknown *create_comment( xmlNodePtr comment );
extern IUnknown *create_cdata( xmlNodePtr text );
extern IXMLDOMNodeList *create_children_nodelist( xmlNodePtr );
extern IXMLDOMNamedNodeMap *create_nodemap( IXMLDOMNode *node );
......
......@@ -146,6 +146,13 @@ static WCHAR szElementXML2[] = {'<','E','l','e','T','e','s','t',' ','A','t','t',
static WCHAR szAttribute[] = {'A','t','t','r',0 };
static WCHAR szAttributeXML[] = {'A','t','t','r','=','"','"',0 };
static WCHAR szCData[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
' ','n','o','t',' ','r','i','g','h','t','!', 0};
static WCHAR szCDataXML[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
'!',']',']','>',0};
static WCHAR szCDataNodeText[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
#define expect_bstr_eq_and_free(bstr, expect) { \
BSTR bstrExp = alloc_str_from_narrow(expect); \
ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
......@@ -1839,6 +1846,7 @@ static void test_xmlTypes(void)
IXMLDOMElement *pElement;
IXMLDOMAttribute *pAttrubute;
IXMLDOMNamedNodeMap *pAttribs;
IXMLDOMCDATASection *pCDataSec;
BSTR str;
IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1; /* Used for testing Siblings */
VARIANT v;
......@@ -2018,6 +2026,58 @@ static void test_xmlTypes(void)
IXMLDOMElement_Release(pElement);
}
/* CData Section */
hr = IXMLDOMDocument_createCDATASection(doc, szCData, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
hr = IXMLDOMDocument_createCDATASection(doc, szCData, &pCDataSec);
ok(hr == S_OK, "ret %08x\n", hr );
if(hr == S_OK)
{
IXMLDOMNode *pNextChild = (IXMLDOMNode *)0x1;
hr = IXMLDOMElement_appendChild(pRoot, (IXMLDOMNode*)pCDataSec, NULL);
ok(hr == S_OK, "ret %08x\n", hr );
/* get Attribute Tests */
hr = IXMLDOMCDATASection_get_attributes(pCDataSec, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
pAttribs = (IXMLDOMNamedNodeMap*)0x1;
hr = IXMLDOMCDATASection_get_attributes(pCDataSec, &pAttribs);
ok(hr == S_FALSE, "ret %08x\n", hr );
ok(pAttribs == NULL, "pAttribs != NULL\n");
hr = IXMLDOMCDATASection_get_nodeName(pCDataSec, &str);
ok(hr == S_OK, "ret %08x\n", hr );
ok( !lstrcmpW( str, szCDataNodeText ), "incorrect cdata node Name\n");
SysFreeString(str);
hr = IXMLDOMCDATASection_get_xml(pCDataSec, &str);
ok(hr == S_OK, "ret %08x\n", hr );
ok( !lstrcmpW( str, szCDataXML ), "incorrect cdata xml\n");
SysFreeString(str);
/* test lastChild */
pNextChild = (IXMLDOMNode*)0x1;
hr = IXMLDOMCDATASection_get_lastChild(pCDataSec, &pNextChild);
ok(hr == S_FALSE, "ret %08x\n", hr );
ok(pNextChild == NULL, "pNextChild not NULL\n");
/* test get_dataType */
hr = IXMLDOMCDATASection_get_dataType(pCDataSec, NULL);
ok(hr == E_INVALIDARG, "ret %08x\n", hr );
hr = IXMLDOMCDATASection_get_dataType(pCDataSec, &v);
ok(hr == S_FALSE, "ret %08x\n", hr );
ok( V_VT(&v) == VT_NULL, "incorrect dataType type\n");
VariantClear(&v);
IXMLDOMCDATASection_Release(pCDataSec);
}
IXMLDOMElement_Release( pRoot );
}
}
......
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