Discussion:
IXMLDOMSchemaCollection2Ptr - how to use "add" method
(too old to reply)
Ketan
2004-11-05 00:23:03 UTC
Permalink
Can anyone provide sample code on how to use the "add" method of
IXMLDOMSchemaCollection when adding a DOMDocument object for the second
parameter of the "add" method, rather than a string indicating the pathname.

Example code snipet:

// Create the DOM Document object for the XSD
IXMLDOMDocument2Ptr pXSDDoc = NULL;
HRESULT hr = pXSDDoc.CreateInstance(__uuidof(DOMDocument40));
pXSDDoc->resolveExternals = VARIANT_TRUE;

// Load the XSD
BSTR bstrXSD;
bstrXSD = I_XSD.AllocSysString();
hr = pXSDDoc->loadXML(bstrXSD);

// Create schema collection object
IXMLDOMSchemaCollection2Ptr pSchemaCollection;
hr = pSchemaCollection.CreateInstance(__uuidof(XMLSchemaCache40));

// Add XSD to schema collection
//Want to know how to do the following (pass in the DOMDocument that
represents
// the XSD. This fails, indicating the parameter is not correct.
hr = pSchemaCollection->add("",pXSDDoc);
// This example with the pathname specifed does work
//hr = pSchemaCollection->add("",_T("C:\\MyDirectory\\MyXSD.xsd"));
--
Ketan
cr
2007-09-26 13:43:19 UTC
Permalink
Post by Ketan
Can anyone provide sample code on how to use the "add" method of
IXMLDOMSchemaCollection when adding a DOMDocument object for the second
parameter of the "add" method, rather than a string indicating the pathname.
// Create the DOM Document object for the XSD
IXMLDOMDocument2Ptr pXSDDoc = NULL;
HRESULT hr = pXSDDoc.CreateInstance(__uuidof(DOMDocument40));
pXSDDoc->resolveExternals = VARIANT_TRUE;
// Load the XSD
BSTR bstrXSD;
bstrXSD = I_XSD.AllocSysString();
hr = pXSDDoc->loadXML(bstrXSD);
// Create schema collection object
IXMLDOMSchemaCollection2Ptr pSchemaCollection;
hr = pSchemaCollection.CreateInstance(__uuidof(XMLSchemaCache40));
// Add XSD to schema collection
//Want to know how to do the following (pass in the DOMDocument that
represents
// the XSD. This fails, indicating the parameter is not correct.
hr = pSchemaCollection->add("",pXSDDoc);
// This example with the pathname specifed does work
//hr = pSchemaCollection->add("",_T("C:\\MyDirectory\\MyXSD.xsd"));
--
Ketan
Long time ago but... i�ve needed many hours to find the answer so:

// the XSD. This fails, indicating the parameter is not correct.
hr = pSchemaCollection->add(_T(""),_variant_t(IDispatchPtr(pXSDDoc), true));


BizTalk Utilities - Frustration free BizTalk Adapters
http://www.topxml.com/biztalkutilities

Loading...