[bdbxml] problem validating in c++
"John O'Donnell" <odonnelj-aVqd/[email protected]>
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <004e01c59752$968c59a0$243fe286@NDSLaptop16> |
Hi,
I am having problems validating an xml file using a schema when I write a small c++ program to open a container in validation mode and then add a document to the container. Whenever i add the xml document to the container I get an error that says "Exception: Error: XML Indexer: Fatal Parse error in document at line 5. char 97. Parse message: An exception occurred! Type:RuntimeException, Message: could not open external entity.". Line 5 is the line containing the schemalocation attribute in my xml document. I know the document and schema are sound as i have validated them using an xml validator. When I open the container and enter the document using the command line instead of a c++ program the operation works perfectly. Below is the code I am using.
Any help would be greatly appreciated.
Thanks,
John
#include <string>
#include <fstream>
#include "dbxml/DbXml.hpp"
using namespace std;
using namespace DbXml;
int main(int argc, char *argv[]) {
try {
XmlInputStream * input = NULL;
string path2DbEnv = "c:/env";
string theContainer = "simpleExampleData.dbxml";
string docName = "John2";
//open a container in the db environment
DbEnv env(0);
env.set_cachesize(0, 64 * 1024 * 1024, 1);
env.open(path2DbEnv.c_str(),
DB_INIT_MPOOL|DB_CREATE|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN, 0);
XmlManager db(&env);
XmlContainer container = db.openContainer(theContainer, DBXML_ALLOW_VALIDATION);
XmlUpdateContext updateContext = db.createUpdateContext();
//create input
input = db.createLocalFileInputStream("c:/shiporder1.xml");
container.putDocument(docName, input, updateContext, 0);
XmlUpdateContext uc = db.createUpdateContext();
} catch (XmlException &e) {
std::cout << "Exception: " << e.what() << std::endl;
}
return 0;
}