GNOME Bugzilla – Bug 157973
Validate Schemata without XML document
Last modified: 2021-07-05 13:22:16 UTC
Sometimes it may be of interest to ensure that ones XML Schema is valid, without (trying to) use it to validate an XML document instance. Hypothetically, it would be practical if: xmllint --noout --schema schema.xsd didn't return an usage error, but loaded the Schema and simply barfed if it wasn't a (valid) Schema. The exact details of xmllint's arguments, is another matter. A relevant thread: http://mail.gnome.org/archives/xml/2004-November/msg00084.html Cheers, Frans
Also, the same is of interest for xsltproc; validating XSLTs, without having to transform a document. Cheers, Frans
for xsltproc, rejected, "xsltproc test.xml" already has a precise definition. Daniel
I bet I've broken more than I've fixed, but I quickly hacked together what is below. Works For Me. Index: xmllint.c =================================================================== RCS file: /cvs/gnome/libxml2/xmllint.c,v retrieving revision 1.133 diff -u -3 -p -r1.133 xmllint.c --- xmllint.c 9 Nov 2004 16:16:59 -0000 1.133 +++ xmllint.c 22 Nov 2004 00:55:33 -0000 @@ -1669,10 +1669,12 @@ static void showVersion(const char *name static void usage(const char *name) { printf("Usage : %s [options] XMLfiles ...\n", name); #ifdef LIBXML_OUTPUT_ENABLED - printf("\tParse the XML files and output the result of the parsing\n"); + printf("\tParse the XML files and output the result of the parsing.\n"); #else - printf("\tParse the XML files\n"); + printf("\tParse the XML files.\n"); #endif /* LIBXML_OUTPUT_ENABLED */ + printf("\tIf no XML files are supplied but a W3C XML Schema is, a loading\n"); + printf("\tis attempted and any errors encountered are reported.\n"); printf("\t--version : display the version of the XML library used\n"); #ifdef LIBXML_DEBUG_ENABLED printf("\t--debug : dump a debug tree of the in-memory document\n"); @@ -2177,7 +2179,6 @@ main(int argc, char **argv) { xmlGenericError(xmlGenericErrorContext, "WXS schema %s failed to compile\n", schema); progresult = XMLLINT_ERR_SCHEMACOMP; - schema = NULL; } xmlSchemaFreeParserCtxt(ctxt); if (timing) { @@ -2294,7 +2295,7 @@ main(int argc, char **argv) { if ((htmlout) && (!nowrap)) { xmlGenericError(xmlGenericErrorContext, "</body></html>\n"); } - if ((files == 0) && (!generate) && (version == 0)) { + if ((files == 0) && (schema == NULL) && (!generate) && (version == 0)) { usage(argv[0]); } #ifdef LIBXML_SCHEMAS_ENABLED
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.