michaelkrauklis
Programmer
I'm having a problem validating an xml file using a Schema and the Xerces SAXParser. The code is as follows:
I believe the problem is it's not loading the Schema correctly, so when I parse and it tries to validate it sends an error each time it reads an element or attribute because it's not expecting anything. world.xsd and the systemid(world.xml) are both in the directory in which the application is running. I'm using VC++6.0 Any help will be greatly appreciated. Thanks.
p.s. This is obviously in C++, but the function in which I'm running this is a member function of a class that implements the DocumentHandler and ErrorHandler interfaces, hence the this reference when setting the DocumentHandler and ErrorHandler for the parser. MYenigmaSELF:-9
myenigmaself@myenigmaself.gaiden.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra
Code:
parser = new SAXParser();
parser->setDoNamespaces(true);
parser->setValidationScheme(SAXParser::Val_Always);
parser->setValidationSchemaFullChecking(true);
parser->setExternalSchemaLocation("world.xsd");
parser->setDocumentHandler(this);
parser->setErrorHandler(this);
try{
cout<<"--Parsing--"<<endl;
const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
parser->parse(systemid);
const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
cout<<endl<<endl<<"Parse duration: "<<(endMillis - startMillis)<<"ms."<<endl;
//*************************************************************************************************
I believe the problem is it's not loading the Schema correctly, so when I parse and it tries to validate it sends an error each time it reads an element or attribute because it's not expecting anything. world.xsd and the systemid(world.xml) are both in the directory in which the application is running. I'm using VC++6.0 Any help will be greatly appreciated. Thanks.
p.s. This is obviously in C++, but the function in which I'm running this is a member function of a class that implements the DocumentHandler and ErrorHandler interfaces, hence the this reference when setting the DocumentHandler and ErrorHandler for the parser. MYenigmaSELF:-9
myenigmaself@myenigmaself.gaiden.com
"If debugging is the process of removing bugs, then programming must be the process of putting them in." --Dykstra