Hi I want to include an xml validation schema as a part of an executable. My problem is how to add the schema to the MSXML2::XMLSchemaCache40. I have a schema called 'setup.xsd', and m_schemaCache is a MSXML2::IXMLDOMSchemaCollection2 interface to XMLSchemaCache40. The following code works ('setup' is the namespace for the schema). hr = m_schemaCache->add(L"setup", L"Setup.xsd");
Now I want to load the schema from a resource. Since IXMLDOMSchemaCollection2::add only accepts url's or MSXML2::DOMDocument's, I decided to parse the xml data using DOMDocument, and then pass the DOMDocument over to the XMLSchemaCache40. In the following code, everything seems to be ok until I try to add the DOMDocument to the XMLSchemaCache40. The resource is loaded, The DOMDocument parses it, and no errors are found. The readyState of the DOMDocument is 4. //Create resource name from resource id wchar_t sResName[10]; swprintf_s(sResName, 10, L"#%d", resourceId); //Locate the resource TCHAR sRestype[13] = _T("SCHEMA"); HRSRC hres = FindResource(NULL, sResName, sRestype); if (hres == 0) { return false; } //If resource is found a handle to the resource is returned //now just load the resource HGLOBAL hbytes = LoadResource(NULL, hres); // Lock the resource LPVOID pdata = LockResource(hbytes); //Convert the resource text file to data we can use LPBYTE sData = (LPBYTE)pdata; BSTR sXml = _bstr_t((char*) sData); //Crate instance of DOM parser MSXML2::IXMLDOMDocument* doc; hr = CoCreateInstance(__uuidof(MSXML2::DOMDocument), NULL, CLSCTX_ALL, __uuidof(MSXML2::IXMLDOMDocument), (void**) &doc); if (FAILED(hr)) return false; //We don't want async read doc->put_async(VARIANT_FALSE); doc->put_validateOnParse(VARIANT_TRUE); //Parse the xml schema we just loaded from our resources VARIANT_BOOL succeeded; hr = doc->loadXML(sXml, &succeeded); if (succeeded != VARIANT_TRUE) { //Load failed return false; } //HERE IT FAILS!!!!!! //Add the loaded schema to the schema collection hr = m_schemaCache->add(bstrNamespace, _variant_t(doc)); if ( FAILED(hr) ) return false; return true;
What am I doing wrong? Thanks in advance for any answers :) øivind
dolph_loe
Posts
-
how to load xml schema from resource? -
directshow sdkI cant find the directshow sdk anywhere..! I downloaded the latest directx sdk, but it seems like it has been excluded from that package. Anybody who knows where I can get it? I am trying to access a webcam. Are there any other ways to do this? øivind
-
ASP .NET vs PHPI've been working with php for a while, but consider switching to asp.. Can anyone tell me what is asp's strong and weak sides compared to php? øivind
-
problem with long c++ fileI have some problems with a c++ file containing about 7000 lines. Sometimes, Visual Studio copies some of the last lines of the file, and prints them at the bottom of the file... only problem is that it doesn't show them in the editor.. I have to reopen the file to find and delete the 'new' code.. anyone having the same problem?? I am using Visual Studio .NET 2003.. øivind
-
Document template problemtnx! had to add the following line
pDocTemplate->m_bAutoDelete = true;
:) øivind
-
Document template problemHI! In my code, I create a document template in the following way:
pDocTemplate = new CMultiDocTemplate(IDR_PHYSEDIT,
RUNTIME_CLASS(CPhysEditDoc),
RUNTIME_CLASS(CPhysEditFrame),
RUNTIME_CLASS(CPhysEditView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);Everything works perfectly, but when the program exits I get the following output: e:\work\c++\project\utilities.cpp(117) : {58} client block at 0x003F4B40, subtype c0, 140 bytes long. a CMultiDocTemplate object at $003F4B40, 140 bytes long {56} normal block at 0x003F49F8, 78 bytes long. Data: < 6 = = > D0 0D 36 10 3D 00 00 00 3D 00 00 00 01 00 00 00 My question is: How do I clean up the document template objects on exit? Shouldn't CWinApp do that? øivind
-
problem with dllthe class is like this: class _declspec(dllexport) jalla { std::list<int> m_mesh; }; øivind
-
problem with dllIn a dll, I define a class in the following way:
class _declspec(dllexport) jalla { std::list m_mesh; };
but when I try to compile it, I get the warning:e:\Work\C++\Project\3DGame\3DSLoader.h(19) : warning C4251: 'jalla::m_mesh' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'jalla' with [ _Ty=int ]
what is happening? øivind -
There is no source code available for the current locationstill doesn't work... :sigh: any other ideas? ØIvIND
-
global variablesmakes sense :)
-
global variablesOk.... dont know if i'm doing things the wrong way, but MSVC.NET gives me the message: The following breakpoint cannot be set: When 'g_resManager' changes Data breakpoints are not supported in the Common Language Runtime. I also tried to dereference g_resManager (which is a pointer) but that gave the same result.. :confused:
-
global variablesI have some global variables in my program, but some of them (pointers) suddenly change without me doing it.. How is this possible? øivind
-
There is no source code available for the current locationHI! When I'm debugging and stepping through my code, in certain places I get the message "There is no source code available for the current location.", even though it is my own code, and the files are in my project... Anyone know how to fix this? Øivind
-
rotate blt ??Is there any way to apply a rotation matrix to a CDC blt? I am trying to draw a rotated bitmap..
-
how to display info about menu items in a dlgWhen you use the appwiz to create a MDI or SDI app, info about each menu item is shown in the statusbar when you hover over the menu item. I have a dialog with a menu and a statusbar. Is there any good way to do this for me? Øivind
-
Setting the cursorWeee! I got it right. I only needed to cast the cursor to (LONG_PTR) and not reference it:
SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) cursor);
-
Setting the cursorWith your code, I don't get any warnings, but the cursor doesn't change.. =(
SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG_PTR) &cursor);
-
Suppress return and escape in a dlgI am creating an app based on CDialog, but whenever I press escape or return, it exits. How do I stop this from happening?? Øivind
-
Setting the cursorI use the following code to set the cursor of a window:
HCURSOR cursor = theApp.LoadStandardCursor(IDC_ARROW); SetClassLongPtr(GetDlgItem(IDC_COLORDISPLAY)->GetSafeHwnd(), GCL_HCURSOR, (LONG) cursor);
The problem is that I get the following compiler warning:warning C4311: 'type cast' : pointer truncation from 'HCURSOR' to 'LONG'
How do I do this the right way?? Øivind -
uml in the IDEI read an article about connectiong Visio and Visual Studio 6, so that visio automaticly reverse engineered your code and created a uml-diagram. I however, have Visual Studio .Net , and I don't know how to connect the two. In the article, they said something about a visio uml add-in, but I don't find it... HELP! =) Øivind