[xml] minor problem with validation...



Hi,

i am currently working myself into libxml. As a starter i looked at xmllint.c 
and grabbed some stuff of it, basically just wanting to validate a given xml 
document.

Here is my code so far:

int main()
{
        xmlDoValidityCheckingDefaultValue = 1;
        char *filename = "verdammnis.xml";
        xmlDocPtr doc = NULL;
        doc = xmlParseFile(filename);
        if (doc == NULL) return(NULL);

        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);
        }
}

This prog basically works as it should, i just have a cosmetic problem. The 
output is this:

verdammnis.xml:0: validity error: No declaration for element asdf
  <asdf>asdljkf</asdf>
                     ^
verdammnis.xml:0: validity error: Element verordnung content does not follow 
the DTD
Expecting (vname , valter), got (vname asdf valter )
 </verordnung>
             ^
verdammnis.xml:0: No declaration for element asdf
Document verdammnis.xml does not validate


When using xmllint i get the following output:

verdammnis.xml:50: Element verordnung content does not follow the DTD
Expecting (vname , valter), got (vname asdf valter )
verdammnis.xml:52: No declaration for element asdf
Document verdammnis.xml does not validate

This output is formatted a little nicer and additionally the line number given 
with the error message. 

How can i archieve this? The output format is not so important, but the line 
number would really be nice. 

Thanks a lot in advance
Matthias



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