Martijn Faassen wrote:
Would you be willing to write a C version of this and post a message to the libxml2 mailing list? If not, let me know, and I'll try to write a C version and report it myself.
Yup, it's a libxml2 bug. Apply the attached patch to testRelax.c in the libxml2-2.6.21 distribution (possibly earlier ones, too). [test]$ ~/src/libxml2-2.6.21/testRelax nbk.rng tut-2.3.5-bad.nbk tut-2.3.5-bad.nbk:17: element ipython-block: Relax-NG validity error : Expecting element ipython-cell, got para tut-2.3.5-bad.nbk:17: element ipython-block: Relax-NG validity error : Element ipython-block failed to validate content Relax-NG validity error : Extra element ipython-block in interleave tut-2.3.5-bad.nbk:17: element ipython-block: Relax-NG validity error : Element sheet failed to validate content tut-2.3.5-bad.nbk fails to validate tut-2.3.5-bad.nbk validates The same problem occurs with the pair of files test/relaxng/docbook{.rng,_0.xml} from the libxml2 source distribution. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter --- libxml2-2.6.21/testRelax.c 2005-01-04 06:49:47.000000000 -0800 +++ testRelax.c 2005-09-09 19:34:34.000000000 -0700 @@ -143,6 +143,23 @@ int ret; ctxt = xmlRelaxNGNewValidCtxt(schema); + xmlRelaxNGSetValidErrors(ctxt, + (xmlRelaxNGValidityErrorFunc) fprintf, + (xmlRelaxNGValidityWarningFunc) fprintf, + stderr); + ret = xmlRelaxNGValidateDoc(ctxt, doc); + if (ret == 0) { + printf("%s validates\n", argv[i]); + } else if (ret > 0) { + printf("%s fails to validate\n", argv[i]); + } else { + printf("%s validation generated an internal error\n", + argv[i]); + } + xmlRelaxNGFreeValidCtxt(ctxt); + + /* Try again */ + ctxt = xmlRelaxNGNewValidCtxt(schema); xmlRelaxNGSetValidErrors(ctxt, (xmlRelaxNGValidityErrorFunc) fprintf, (xmlRelaxNGValidityWarningFunc) fprintf,