Dominic,
in the call to setExternalSchemaLocation the first part must be the
namespace of the schema, and
"http://www.insite.ch/schemas/FAK_CAF_Benefits_minimal.xsd" looks
suspicious. What is the value of the targetNamespace attribute in the
xs:schema root element of
C:/projekte/_dev20/insiteSV/insiteFAK/_Bin/FAK_CAF_Benefits_minimal.xsd?
Alberto
Egger Dominic wrote:
Dear Xercescomunity,
I've got a little problem, I'd like to validate an XML according an
XSD where in the namespacedeclarations the XSD-Path aren't correct.
So i use setExternalSchemaLocation but I don't get it working, it
parses the XML but doesn't validate. I use 2.8 since I din't get 3.0
working.
* #include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <stdio.h>
#include <fstream>
#if defined(XERCES_NEW_IOSTREAMS)
#include <iostream>
#else
#include <iostream.h>
#endif
XERCES_CPP_NAMESPACE_USE
using namespace std;
int main (int argc, char* args[]) {
ofstream myfile;
myfile.open ("C:/validateMSG.txt");
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
myfile << "Error during initialization! :\n"
<< message << "\n";
XMLString::release(&message);
return 1;
}
XercesDOMParser* parser = new XercesDOMParser();
parser->setValidationScheme(XercesDOMParser::Val_Always);
parser->setDoNamespaces(true); // optional
parser->setDoSchema(true);
parser->setExternalSchemaLocation("http://www.insite.ch/schemas/FAK_CAF_Benefits_minimal.xsd
C:/projekte/_dev20/insiteSV/insiteFAK/_Bin/FAK_CAF_Benefits_minimal.xsd");
//parser->setExternalNoNamespaceSchemaLocation("C:/projekte/_dev20/insiteSV/insiteFAK/_Bin/FAK_CAF_Benefits.xsd");
//parser->loadGrammar("C:/projekte/_dev20/insiteSV/insiteFAK/_Bin/FAK_CAF_Benefits.xsd",
1, true);
ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
parser->setErrorHandler(errHandler);
char* xmlFile = "C:/temp/fak_dta/error/2009-08-24
13.09.54/FaK.xml";
//char* xmlFile = "C:/work/FAK_Abrechnung_072009.xml";
try {
parser->parse(xmlFile);
}
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
myfile << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (const DOMException& toCatch) {
char* message = XMLString::transcode(toCatch.msg);
myfile << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch(const SAXException& toCatch)
{
char* message = XMLString::transcode(toCatch.getMessage());
myfile << "Exception message is: \n"
<< message << "\n";
XMLString::release(&message);
return -1;
}
catch (...) {
myfile << "Unexpected Exception \n";
return -1;
}
myfile.close();
delete parser;
delete errHandler;
return 0;
}
*
Thats my source.
Im not really good at c++ so excuse the sloppy code.
Thank you,
Dominic Egger
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]