开发者

Analysis for an XML parsing (and validating) C program

Thanks to jmbr at Stack Overflow, I finally found a way to validate xml against RELAX NG via a C program. The program is as follows...

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/relaxng.h>

int main(int argc, char *argv[])
{
   int status;
   xmlDo开发者_如何学Cc *doc;
   xmlRelaxNGPtr schema;
   xmlRelaxNGValidCtxtPtr validctxt;
   xmlRelaxNGParserCtxtPtr rngparser;

   doc = xmlParseFile(argv[1]);

   rngparser = xmlRelaxNGNewParserCtxt(argv[2]);
   schema = xmlRelaxNGParse(rngparser);
   validctxt = xmlRelaxNGNewValidCtxt(schema);

   status = xmlRelaxNGValidateDoc(validctxt, doc);
   printf("status == %d\n", status);

   xmlRelaxNGFree(schema);
   xmlRelaxNGFreeValidCtxt(validctxt);
   xmlRelaxNGFreeParserCtxt(rngparser);
   xmlFreeDoc(doc);
   exit(EXIT_SUCCESS);

}

I have, since then, significantly tweaked the program so as to find out the "processing time" for parsing and validating an xml file. Is there any way to find out the best case and worst case for this program. Worst case being, the time taken is always highest for any xml file as input. And best case being, the time taken is always lowest. I am really stuck at this. Would really appreciate it, if any of you guys could help me out.


To test your code you should make different test plan & test case.. in that case Try different different xml input file ...

1 file who whose nesting so many times

any missed tag xml file (not valid xml file)

xml file who has no doctype or tags are in differently coded

& for processing time calculation use time.h

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜