Re: [xml] xmlSchemaValidateDoc: return value -1 ?



ok, thanx for the reply.
do i make the api/interna's crash? Here is my code:

xmlDocPtr doc ;
    xmlSchemaParserCtxtPtr schema_parser_ptr ;
    xmlSchemaPtr schema_ptr ;
    xmlSchemaValidCtxtPtr schema_valid_ptr ;
int valid;

  LIBXML_TEST_VERSION ;

    if( (schema_parser_ptr = xmlSchemaNewParserCtxt(argv[1])) == NULL ){

        fprintf(stderr,"schema cannot be initted\n") ;
        return -1 ;
    }


    if( (schema_ptr = xmlSchemaParse(schema_parser_ptr) == NULL)){

        fprintf(stderr,"cannot parse the Schema\n") ;
        xmlSchemaFreeParserCtxt(schema_parser_ptr) ;
        return -1 ;
    }

    if( (schema_valid_ptr = xmlSchemaNewValidCtxt(schema_ptr) == NULL)){

        fprintf(stderr,"schema is not valid\n") ;
        xmlSchemaFree(schema_ptr);
        xmlSchemaFreeParserCtxt(schema_parser_ptr) ;
        return -1 ;
    }


    fprintf(stdout,"argv[2] value:%s\n",argv[2]) ;
    /* read file into a tree */
    if( (doc = xmlReadFile(argv[2], NULL, 0))  == NULL){

        fprintf(stdout,"Cannot parse the file \n");
        return -1;
    }

 if( (valid = xmlSchemaValidateDoc(schema_valid_ptr, doc)) == 1 ) {

        fprintf(stdout, "cannot validate the xml document with given schema!\n") ;
        return -1 ;
    }


so, valid comes out with -1. If the problem is api/internal errors is there any workaround?

Thanx in advance,



-----Ursprüngliche Nachricht-----
Datum: Tue, 22 Apr 2008 19:12h
Von: "ashwin sinha" <4shw1ns1nh4 gmail com>
An: j s bach o2online de
Kopie: xml gnome org
Betreff: Re: [xml] xmlSchemaValidateDoc: return value -1 ?


Hi ,

>Is -1 thought for successfull validation? Can you put a bit doc at least on what should be
>expected for return values?

 /**
 * xmlSchemaValidateDoc:
 * @ctxt:  a schema validation context
 * @doc:  a parsed document tree
 *
 * Validate a document tree in memory.
 *
 * Returns 0 if the document is schemas valid, a positive error code
 *     number otherwise and -1 in case of internal or API error.
 */





_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]