Re: [xml] xml help



On Mon, Dec 10, 2001 at 11:26:34AM -0800, Michael Picheca wrote:
I tried using the xmlDoValidityCheckingDefaultValue =1 that you suggested and 
I 
need to be able to halt the program after the validation with the dtd listed 
within the xml file fails. How do I do that? Is there a return value or 
something that I can use to invoke a halt? WHen I was using xmlValidateDtd it 
would return 0 if it failed and I would halt the program at this point.


  The problem is taht interfaces like xmlParseFile don't allow you
to do this !
  You need to use more advanced interfaces like the ones used in xmllint.c
where you create your own parser context:
  Look at xmllint.c code, somethings like the following should work:

    xmlParserCtxtPtr ctxt;

    xmlDoValidityCheckingDefaultValue =1;
    ctxt = xmlCreateFileParserCtxt(filename);

    xmlParseDocument(ctxt);
    ret = ctxt->wellFormed;
    valid = ctxt->valid;
    doc = ctxt->myDoc;
    xmlFreeParserCtxt(ctxt);
    if (!ret) {
        xmlFreeDoc(doc);
        doc = NULL;
    }

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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