Ketan
2004-11-05 00:23:03 UTC
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"));
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
Ketan