[xml] Ability to plug in schema validation on top libxml2 SAX parser
- From: Sarmishtha Bhattacharya <sarmishtha bhattacharya gmail com>
- To: xml gnome org
- Subject: [xml] Ability to plug in schema validation on top libxml2 SAX parser
- Date: Thu, 3 Mar 2011 14:05:54 -0800
Hi,
I tried using xmlSchemaValidateStream() but i get error, the snippet of the
code i writing is:
xmlSAXHandler* saxHandler = new xmlSAXHandler();
saxHandler->initialized = XML_SAX2_MAGIC;
saxHandler->startElement = &ParseData::start_parse;
saxHandler->endElement = &ParseData::end_parse;
saxHandler->characters = &ParseData::value_parse;
ParseData pdata;
xmlParserInputBufferPtr buf = NULL;
buf = xmlParserInputBufferCreateMem(xmlstr.c_str(), int(xmlstr.length()),
XML_CHAR_ENCODING_NONE);
int ret = xmlSchemaValidateStream(ctxt, buf, XML_CHAR_ENCODING_NONE, saxHandler,
&pdata);
if (ret == 0)
cout<<"validated "<<endl;
else if (ret > 0)
cout<<"validation failed"<<endl;
else
cout<<"Some internal error while validation"<<endl;
the return value from
xmlSchemaValidateStream() is <0. Could you see why it would be so?
Thanks,
Sarmishtha
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]