I trying to write a xsd validator utility using MSXML 6.0. All is fine and nice except this one line :
this->myReader->putProperty(L"schemas", pXS);
This throws this error : error C2664: 'ISAXXMLReader::putProperty' : cannot convert parameter 2 from 'MSXML2::IXMLDOMSchemaCollectionPtr' to 'VARIANT'
which is understandable but how can one add a schema instance to a reader?
FYI myReader is this :
ISAXXMLReader * myReader;
and initialized like this :
HRESULT hr = CoCreateInstance( __uuidof(SAXXMLReader60),
NULL,
CLSCTX_ALL,
__uuidof(ISAXXMLReader),
(void **)&this->myReader);
And pXS is :
MSXML2::IXMLDOMSchemaCollectionPtr pXS;
pXS.CreateInstance(__uuidof(MSXML2::XMLSchemaCache60), NULL, CLSCTX_INPROC_SERVER);
Some of the links I read :
http://msdn.microsoft.com/en-us/library/ms762787(v=VS.85).aspx
http://support.microsoft.com/kb/309535
http://msdn.microsoft.com/en-us/library/windows/desktop/cc507429(v=VS.85).aspx
As usual MSDN documentation is really nice..
The example they provide works, but I need to collect all errors, so I translated the vb example in one of the links to C++. The only error which remains is this. Any help is appreciated.
Edit:
After following this nice link:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms766451(v=vs.85).aspx
C++ section :
The namespace to associate with the specified schema.
The empty string, “”, will associate the schema with the empty namespace, xmlns=””.
And doing this:
nResult = pIXMLDOMSchemaCollection2Ptr->add(_T(""), _T("c:\\temp\\collection.xsd"));
A nice crash happens. Does anyone know how on earth to add a schema without namespace in this thing?
OK after searching through I found the solution to my problem:
Hopefully someone else will benefit from this.
Edit:
How to add an empty namespace:
Pay attention to this line :
_bstr_t bstrNamespace = ns.c_str();