#include <olectl.h>
#include <objsafe.h>
-#include <wine/list.h>
-
#ifdef HAVE_LIBXML2
/* not defined in older versions */
xmlChar const* selectNsStr;
LONG selectNsStr_len;
BOOL XPath;
+ WCHAR *url;
} domdoc_properties;
typedef struct ConnectionPoint ConnectionPoint;
VARIANT_BOOL validating;
VARIANT_BOOL resolving;
domdoc_properties* properties;
- bsc_t *bsc;
HRESULT error;
- /* IObjectWithSite*/
+ /* IObjectWithSite */
IUnknown *site;
/* IObjectSafety */
properties->version = version;
properties->XPath = (version == MSXML4 || version == MSXML6);
+ /* document url */
+ properties->url = NULL;
+
return properties;
}
list_add_tail(&pcopy->selectNsList, &new_ns->entry);
}
+ if (properties->url)
+ {
+ int len = strlenW(properties->url);
+
+ pcopy->url = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
+ memcpy(pcopy->url, properties->url, len*sizeof(WCHAR));
+ pcopy->url[len] = 0;
+ }
+ else
+ pcopy->url = NULL;
}
return pcopy;
IXMLDOMSchemaCollection2_Release(properties->schemaCache);
clear_selectNsList(&properties->selectNsList);
heap_free((xmlChar*)properties->selectNsStr);
+ CoTaskMemFree(properties->url);
heap_free(properties);
}
}
{
int eid;
- if(This->bsc)
- detach_bsc(This->bsc);
-
if (This->site)
IUnknown_Release( This->site );
destroy_xmlnode(&This->node);
xmlChar* tagName_to_XPath(const BSTR tagName)
{
xmlChar *query, *tmp;
+ static const xmlChar everything[] = "/descendant::node()";
static const xmlChar mod_pre[] = "*[local-name()='";
static const xmlChar mod_post[] = "']";
static const xmlChar prefix[] = "descendant::";
const WCHAR *tokBegin, *tokEnd;
int len;
+ /* Special case - empty tagname - means select all nodes,
+ except document itself. */
+ if (!*tagName)
+ return xmlStrdup(everything);
+
query = xmlStrdup(prefix);
tokBegin = tagName;
}
xml_name = xmlchar_from_wchar(name);
- /* prevent empty href to be allocated */
+ /* prevent empty href from being allocated */
href = namespaceURI ? xmlchar_from_wchar(namespaceURI) : NULL;
switch(node_type)
xmlnode = xmlNewDocNode(get_doc(This), NULL, local ? local : xml_name, NULL);
- /* allow to create default namespace xmlns= */
+ /* allow creating the default namespace xmlns= */
if (local || (href && *href))
{
xmlNsPtr ns = xmlNewNs(xmlnode, href, prefix);
return attach_xmldoc(This, xmldoc);
}
- return S_OK;
+ return E_FAIL;
}
static HRESULT domdoc_load_moniker(domdoc *This, IMoniker *mon)
if(FAILED(hr))
return hr;
- if(This->bsc) {
- hr = detach_bsc(This->bsc);
- if(FAILED(hr))
- return hr;
- }
-
- This->bsc = bsc;
- return S_OK;
+ return detach_bsc(bsc);
}
static HRESULT WINAPI domdoc_load(
case 1:
/* Only takes UTF-8 strings.
* NOT NULL-terminated. */
- SafeArrayAccessData(psa, (void**)&str);
+ hr = SafeArrayAccessData(psa, (void**)&str);
+ if (FAILED(hr))
+ {
+ This->error = hr;
+ WARN("failed to access array data, 0x%08x\n", hr);
+ break;
+ }
SafeArrayGetUBound(psa, 1, &len);
if ((xmldoc = doparse(This, str, ++len, XML_CHAR_ENCODING_UTF8)))
{
IMoniker *mon;
+ CoTaskMemFree(This->properties->url);
+ This->properties->url = NULL;
+
hr = create_moniker_from_url( filename, &mon);
if ( SUCCEEDED(hr) )
{
hr = domdoc_load_moniker( This, mon );
+ if (hr == S_OK)
+ IMoniker_GetDisplayName(mon, NULL, NULL, &This->properties->url);
IMoniker_Release(mon);
}
static HRESULT WINAPI domdoc_get_url(
IXMLDOMDocument3 *iface,
- BSTR* urlString )
+ BSTR* url )
{
domdoc *This = impl_from_IXMLDOMDocument3(iface);
- FIXME("(%p)->(%p)\n", This, urlString);
- return E_NOTIMPL;
+
+ TRACE("(%p)->(%p)\n", This, url);
+
+ if (!url)
+ return E_INVALIDARG;
+
+ if (This->properties->url)
+ {
+ *url = SysAllocString(This->properties->url);
+ if (!*url)
+ return E_OUTOFMEMORY;
+
+ return S_OK;
+ }
+ else
+ return return_null_bstr(url);
}
if (!This->namespaces)
{
- hr = SchemaCache_create(This->properties->version, NULL, (void**)&This->namespaces);
+ hr = SchemaCache_create(This->properties->version, (void**)&This->namespaces);
if (hr != S_OK) return hr;
hr = cache_from_doc_ns(This->namespaces, &This->node);
doc->error = S_OK;
doc->site = NULL;
doc->safeopt = 0;
- doc->bsc = NULL;
doc->cp_list = NULL;
doc->namespaces = NULL;
memset(doc->events, 0, sizeof(doc->events));
return S_OK;
}
-HRESULT DOMDocument_create(MSXML_VERSION version, IUnknown *pUnkOuter, void **ppObj)
+HRESULT DOMDocument_create(MSXML_VERSION version, void **ppObj)
{
xmlDocPtr xmldoc;
HRESULT hr;
- TRACE("(%d, %p, %p)\n", version, pUnkOuter, ppObj);
+ TRACE("(%d, %p)\n", version, ppObj);
xmldoc = xmlNewDoc(NULL);
if(!xmldoc)
#else
-HRESULT DOMDocument_create(MSXML_VERSION version, IUnknown *pUnkOuter, void **ppObj)
+HRESULT DOMDocument_create(MSXML_VERSION version, void **ppObj)
{
MESSAGE("This program tried to use a DOMDocument object, but\n"
"libxml2 support was not present at compile time.\n");