Re: [xml] RV: Validating DTDs



On Fri, Jun 07, 2002 at 10:25:19AM +0200, Samuel Díaz wrote:
      I'm a Spanish user of the libxml 2, my question is that I'm looking for a
function to validate a loaded xmlDoc versus its DTD. I found the function
xmlValidateDtd, that apears to be that I'm looking for, but I need a
xmlValidCtxtPtr.
      The problem is this xmlValidCtxtPtr, I didn't found a constructor to this
datatype and I don't know how to use its.
      I use the xmlParseFile() to have the xmlDocPtr operative, and I use the
xmlGetIntSubset() to get the xmlDtdPtr asociated to my XML document, but I
don't found in the web documentation how to validate my xmlDocPtr against
its xmlDtdPtr.
      Is there any example that can help me? Can you help me?
      Thank you.

  First in your case xmlValidateDocument() is preferable to xmlValidateDtd()
since the DTD is already present in your document. There is of course
and example in the sources of the library more precisely in xmllint.c
for the option postvalidate:

--------------------------
        xmlValidCtxt cvp;

        cvp.userData = (void *) stderr;
        cvp.error    = (xmlValidityErrorFunc) fprintf;
        cvp.warning  = (xmlValidityWarningFunc) fprintf;
        if (!xmlValidateDocument(&cvp, doc)) {
            xmlGenericError(xmlGenericErrorContext,
                    "Document %s does not validate\n", filename);
        }
--------------------------

  that simple. You really need a constructor for this ?

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]