GNOME Bugzilla – Bug 128904
RNG error messages could be improved, perhaps
Last modified: 2021-07-05 13:21:47 UTC
$ xmllint --version /home/tobi/bulk/run/libxml/2.6.2/bin/xmllint: using libxml version 20602 compiled with: DTDValid FTP HTTP HTML C14N Catalog XPath XPointer XInclude Iconv Unicode Regexps Automata Schemas Hi When I validate invalid documents against an RNG then often I don't know what I should fix; below are some examples. Here's the test data: $ cat list.rng <?xml version="1.0"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <start> <ref name="list-element"/> </start> <define name="list-element"> <element name="list"> <attribute name="version"> <value type="string">0.1</value> </attribute> <zeroOrMore> <ref name="item-element"/> </zeroOrMore> </element> </define> <define name="item-element"> <element name="item"> <text/> </element> </define> </grammar> $ cat list.xml <?xml version="1.0"?> <list version="0.1"> <item/> </list> $ xmllint --noout --relaxng list.rng list.xml list.xml validates 1. Missing Attribute When I remove the required attribute $ cat list.xml <?xml version="1.0"?> <list> <item/> </list> I get $ xmllint --noout --relaxng list.rng list.xml list.xml:2: element list: Relax-NG validity error : Element list failed to validate attributes list.xml fails to validate Perhaps it would be possible to report something like "list.xml:2: element list: Relax-NG validity error : Required attribute 'version' missing." 2. Invalid Attribute Value When I add the required attribute but supply an invalid value, I get the same error message; in this case it might be possiible be be more specific as well, eg: "[...] Attribute 'version' must have value '0.1'." 3. Invalid Text When there is invalid text: $ cat list.xml <?xml version="1.0"?> <list version="0.1"> <item/> invalid text in line 4 </list> I get "list.xml:2: element list: Relax-NG validity error : Did not expect text in element list content" When the document has many lines then it's not easy to find the place where to make the correction. Perhaps it would be possible to report the line in which the invalid text is located (/starts), in this case this would mean reporting line 4 instead of line 2. Tobi
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.