Re: [xml] libxml2 does xmlSchemaValidateDoc() support xml schema extensions?

On 12/12/2011 09:12 PM, Andy Davidson wrote:
Does anyone know if libxml2
supports   ?

Yes, libxml2 does support complex type derivation by extension. I am
aware of one bug inside libxml2 schema processing, but that is with
simple-list-type extensions, and it does not apply in your case.

Do I need to tweak my validation code ? 
I think so.
Your instance document with your attached schema validates fine with
xmllint (libxml2 validation tool):

$ xmllint --noout zoo.xml --schema zoo.xsd
zoo.xml validates

I wrote a sample program (in C) to attempt to mimic what you have, and
was able to successfully validate the instance against the schema you

$ ./zoo zoo.xml zoo.xsd
Attempting to validate zoo.xml with zoo.xsd
Document in zoo.xml is valid

One thing I would suggest is NOT releasing any of the resources
associated with the schema before validation (do that after, instead).

    //xmlSchemaFree(schema); causes crash when we try to use validCtxt
    int error = xmlSchemaValidateDoc(validCtxt.validCtxt, doc);       
    if (error == 0) {
        NSLog(@"document is a valid instance of %@", schemaFileName);
        ret = YES;

Also, what's the difference between passing validCtxt instead of
validCtxt.validCtxt into the xmlSchemaValidateDoc() function?

Good luck!

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