Hi All, I am validating a xml message with XML schema in multiple files. XML message has no reference to schema. I am getting "Element : No matching global declaration available for the validation root. schema error" error message. Can you please tell me how to solve it.
I have given the source code here. xmlDocPtr schema_doc = xmlReadFile("fixml-main-4-4.xsd", NULL, XML_PARSE_NONET); if (schema_doc == NULL) { /* the schema cannot be loaded or is not well-formed */ return -1; } xmlSchemaParserCtxtPtr parser_ctxt = xmlSchemaNewDocParserCtxt (schema_doc); if (parser_ctxt == NULL) { /* unable to create a parser context for the schema */ xmlFreeDoc(schema_doc); return -2; } xmlSchemaPtr schema = xmlSchemaParse(parser_ctxt); if (schema == NULL) { /* the schema itself is not valid */ xmlSchemaFreeParserCtxt(parser_ctxt); xmlFreeDoc(schema_doc); return -3; } xmlSchemaValidCtxtPtr valid_ctxt = xmlSchemaNewValidCtxt(schema); if (valid_ctxt == NULL) { /* unable to create a validation context for the schema */ xmlSchemaFree(schema); xmlSchemaFreeParserCtxt(parser_ctxt); xmlFreeDoc(schema_doc); return -4; } xmlSchemaSetValidErrors(valid_ctxt, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); doc = xmlReadMemory(buffer, size, "noname.xml", NULL, 0); if (doc == NULL) { fprintf(stderr, "Failed to parse document\n"); return; } #if 1 int nRet; if((nRet = xmlSchemaValidateDoc(valid_ctxt, doc)) != 0) { fprintf(stderr, "schema error\n"); return; } #endif cur = xmlDocGetRootElement(doc); if (cur == NULL) { fprintf(stderr,"empty document\n"); xmlFreeDoc(doc); return; } _______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel