GNOME Bugzilla – Bug 523004
schema validation versus a smil document
Last modified: 2019-09-16 14:41:28 UTC
Please describe the problem: I need to validate a smil document with the xml schema published by W3C ("http://www.w3.org/2001/SMIL20/smil20.xsd"). I use the interface to the XML Schemas of LibXml2 and it returns several parse errors about the smil xml schema document. Steps to reproduce: I write the piece of code I used (I started from example files present in www.xmlsoft.org): static void streamFile(const char *filename) { xmlTextReaderPtr reader; int ret; /* * Pass some special parsing options to activate DTD attribute defaulting, * entities substitution and DTD validation */ reader = xmlNewTextReaderFilename(filename); if (reader != NULL) { ret = xmlTextReaderRead(reader); while (ret == 1) { processNode(reader); ret = xmlTextReaderRead(reader); } xmlSchemaParserCtxt* schemaParser = xmlSchemaNewParserCtxt("http://www.w3.org/2001/SMIL20/smil20.xsd"); if (schemaParser) { xmlSchema* schema = xmlSchemaParse(schemaParser); if (schema) { xmlSchemaValidCtxt* validityContext = xmlSchemaNewValidCtxt(schema); if (validityContext) { // Returns 0 if validation succeeded int result = xmlSchemaValidateFile(validityContext, filename, 0) == 0; xmlSchemaFreeValidCtxt(validityContext); } xmlSchemaFree(schema); } xmlSchemaFreeParserCtxt(schemaParser); } } else { fprintf(stderr, "Unable to open %s\n", filename); } } Actual results: Parser displays these errors: http://www.w3.org/2001/SMIL20/smil20-layout.xsd:206: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:207: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:208: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:209: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:210: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. Expected results: No errors about the xml schema. Does this happen every time? yes. Other information: I first tried with a simple xml schema written in a local file and all worked fine.
Provide a minimal test case reproducing the problem please with xmllint. There is no way I will ever get time to analyze your code, the SMIL XSD and guess what kind of instance you may have used. Daniel
(In reply to comment #1) > Provide a minimal test case reproducing the problem please with xmllint. > There is no way I will ever get time to analyze your code, the SMIL XSD > and guess what kind of instance you may have used. > > Daniel > OK Daniel, excuse me. For me it's the first time I submitted a bug here. First of all, "xmllint --version": xmllint: using libxml version 20631 compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Then, I used "xmllint" in this way: xmllint --schema "http://www.w3.org/2001/SMIL20/smil20.xsd" smil_example.xml And the errors while loading the smil xml schema are: http://www.w3.org/2001/SMIL20/smil20-layout.xsd:206: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:207: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:208: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:209: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. http://www.w3.org/2001/SMIL20/smil20-layout.xsd:210: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'http://www.w3.org/2001/SMIL20/Language' are not allowed, since not indicated by an import statement. WXS schema http://www.w3.org/2001/SMIL20/smil20.xsd failed to compile I attach the xml sample file "smil_example.xml". Best regards. Alberto
Created attachment 107534 [details] Example of a smil document to run the test
No idea if it's a bug in libxml2 or not. smil20.xsd includes smil20-layout.xsd around line 22 smil20-layout.xsd uses a reference to a namespaced type the bindings seems to be done with import statements in smil20.xsd but after the include. I don't understand the XSD Part 1 spec, I have no idea if it's legal to bind to something which was not imported yet at that point. If you understand the XSD spec, please point me to the explanations that's welcome ! If you don't understand it, may I suggest using something which actually has a clar semantic like Relax-NG, thanks, Daniel
Hi Daniel, I'm not a XSD expert so I wrote to W3C about this problem. As soon as they reply, I'll report to you the answer. Alberto
Hi Daniel, finally I received an answer from W3C. They confirmed me that there is a problem in the xml schema definition: >>> I have verifyed the XML Schema for SMIL 2.0. (http://www.w3.org/2001/SMIL20/smil20.xsd >>> ) >>> >>> The schema is NOT correct. >>> >>> So, by far, the best thing to do is to work with the SMIL 2.1 DTD. >>> So, this is not a LibXml2 bug. Sorry for opened this bug. Thanks for the support. Alberto