dagwieers / asciidoc-odf

ODF backend for AsciiDoc
98 stars 26 forks source link

a2x should do syntax check using RelaxNG #27

Open dagwieers opened 12 years ago

dagwieers commented 12 years ago

Now that we have xmllint patched for proper RelaxNG syntax checking, we might want to integrate RelaxNG syntax checking of content.xml before packaging.

However, since there are still some issues with the output that are not important, maybe only do this when -v is added ? And disregard the return code until we are safe :-)

elextr commented 12 years ago

That should be easy, the backend can tell a2x to ignore the non-zero return code. The errors don't print unless verbose anyway but maybe we always want to print "Warning: xmllint found errors, continuing anyway"

elextr commented 12 years ago

Committed possible implementation, I don't have hg a2x or patched xmllint so it is untested, use -L to disable, use backend-opt schema=path to set the schema to use.

dagwieers commented 12 years ago

Yesterday I did a rather deep investigation to the xmllint errors that are still apparent with our ODF output. I found that the OpenDocument RelaxNG schema actually seems to require a certain ordening of child-elements, e.g. for style:style parent element. The fact that xmllint (and even jing) do not make it very clear that this strict order is required makes the output confusing (and seemingly wrong). I opened a ticket during the investigation explaining the details: https://bugzilla.redhat.com/show_bug.cgi?id=790316

I also discovered that if a RelaxNG tool complains about interleave/interleaving, it basically has to do with the order of elements, and the output often is plain wrong. It complains about expecting the first element of the possible set (even if this element is not mandatory). So the error is incorrect and deceiving.

Jing is often somewhat better in the error output, but xmllint is more likely to be installed.

Now, with those issues resolved, xmllint return code is reliable, except that due to a bug in xmllint (unimplemented block for XML_RELAXNG_OPTIONAL) most, if not all, xmllint's in the field will fail to validate ODF documents. See: https://bugzilla.redhat.com/show_bug.cgi?id=752393

So we'll have to be very careful, maybe in a year or two most xmllint implementations have this bug fixed :-/

dagwieers commented 12 years ago

If the schema would not be that big, we could consider shipping it with asciidoc-odf...

xamox commented 12 years ago

Thanks using a2x -L allowed it to work for me.