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
      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)) {
                    "Document %s does not validate\n", filename);

  that simple. You really need a constructor for this ?


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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