GNOME Bugzilla – Bug 157205
Support for XMLSchema-instance
Last modified: 2021-07-05 13:22:27 UTC
Support for W3C XMLSchema-instance, the ability to specify a schema in a document instance, is missing. Namespace: http://www.w3.org/2001/XMLSchema-instance Specification: http://www.w3.org/TR/xmlschema-1/ A relevant thread(as of this time of submission): http://mail.gnome.org/archives/xml/2004-November/msg00023.html Cheers, Frans
The functionality is initially implemented but not yet accessible via xmllint.
I'm thinking about the design of xmllint's parameters. AFAICT, it would be practical if the user didn't have to be concerned about whether the XML document referenced an XML Schema or DTD, such that one would have to use a specific parameter. Instead one could do `xmllint --valid file.xml` and it would be automatically detected whether a Schema or DTD was referenced, and then validated accordingly. In addition, could there be --dtdvalid and --xsdvalid, such that it also would be possible to get an error if a wrong type of document declaration was used. Also, perhaps a beta version could go into a real release, since it is an optional, and explicitly activated feature. Cheers, Frans
Nothing prevent a document from referencing both a DTD and a XSD schemas. DTD checking is a parsing process done as part of XML definition. It really doesn't sit at the same level as XSD validation. Daniel
Ok, that's apparently over my head. To express my wish in a way which doesn't touch implementation aspects; it would be practical if one could say to xmllint "validate this file" and then it's validated, regardless of it references a Schema, DTD, or both, such that the user doesn't have to bother if the file references a Schema, DTD, or both. Cheers, Frans
I think the current state is that we decided to add an option to xmllint in order to let it validate against a schema specified by xsi:schemaLocation and/or xsi:noNamespaceSchemaLocation in the instance document. The questions left: 1) what should be the name of the option (e.g. --wxs-xsi-location-validate) 2) what should be done if the option --schema (and a schema document) is also specified. I would prefer to raise an argument error in this case. Additionally, I would like to add the option --wxs-validate. In contrast to --schema, which can also be used without an instance document, it would require an instance document and, due to the "wxs" prefix, it will make it more obvious that we want an XML Schema validation.
I would favor --xsischemas that's simpler, xsi indicates it's the one in the instance and schemas as in --schemas for xsd Daniel
I would prefer to have more explicit names. Although I wouldn't say that I hate W3C XML Schema :-), I think that it does not deserve to have the generic name "schema" reserved for it; so it we could use "wxs", then this would put it in its slot where it belongs. Also "location" seems more intuitive and would prevent us from ambiguity if the W3C decides to add new XSI mechanisms. But the most important reason for an explicit option like --wxs-xsi-location-validate is: the user will be more reluctant to use that option :-)
Ah, I forgot to write that I'm also fine with --xsischema if the explicit version is not accepted. The name might not be as important as I currently think it is.
Is it possible that the two get combined? For example "xmllint file.xml --xsi --schema file.xsd" could mean "attempt to validate file.xml with the schema referenced in it, and use file.xsd if there's no such XML Schema". If the same could be done for DTDs, it would be even better, especially if DTDs could be combined with XML Schemas, so that validation could be done for both, i.e. "xmllint file.xml --xsi --schema file.xsd --valid --dtdvalid file.dtd" would mean "attempt to validate file.xml by both its DTD and its referenced XML Schema, and use file.dtd and file.xsd if respectively there's no referenced DTD and/or XML Schema". Would such a behavior be acceptable? If not, why not?
No there is no combination like that. --valid will look for a DTD in the document --dtdvalid will try to validate against an instance but operation are not at the same time and both could actually be run to verify validity against both. The options are independant. Daniel
So... no "xmllint file.xml --valid --dtdvalid file.dtd" but possible "xmllint file.xml --xsi --schema file.xsd" "xmllint file.xml --xsi --schema file.xsd --valid" "xmllint file.xml --xsi --schema file.xsd --dtdvalid file.dtd" "xmllint file.xml --schema file.xsd --valid" "xmllint file.xml --schema file.xsd --dtdvalid file.dtd" ?
Hello, Is there any update on this issue? I really want to use xmllint for my project, but having to explicitly tell it about the schema to validate against when that same schema is specified within the XML document is rather troubling. If there's nothing that can be done about this issue, then I'm afraid I'm forced to choose Xerces for XML validation simply because it just figures out what validation scheme it must use. Thanks, Deepankar
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.