On Thu, Mar 03, 2011 at 02:05:54PM -0800, Sarmishtha Bhattacharya wrote:
> 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?

  Minimal engineer logic would obviously point out that for a schemas to
validate an XML you would need to pass both the schemas and the XML.
Nowhere in the code pasted there is information about a schemas to use. I
don't have a cristal ball, and I don't know how to program one either.
On the other hand you have complete working code reusable for this purpose
in the xmllint.c file part of the distriubution as I previously pointed
out.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
[email protected]  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to