GNOME Bugzilla – Bug 635641
schema compiler should ignore unknown attributes
Last modified: 2013-10-28 23:39:00 UTC
Running glib-compile-schemas --strict --dry-run --schema-file test.gschema.xml on this schema: <schemalist my:attr="foo"> </schemalist> gives this error: test.gschema.xml: Error on line 2 char 1: attribute 'my:attr' invalid for element 'schemalist'. IMHO, the schema compiler should ignore unknown attributes (esp. those in non-default namespaces). This allows the schema writer to include attributes aimed not at the schema compiler, to re-use the same schema file with other tools.
What other tools would parse the scheme files?
I'm working on a code generator. Another reason to ignore unknown attributes is forward compatibility.
note that schema files are GMarkup and not XML, strictly speaking. one of the simplifications is that GMarkup doesn't grok XML namespaces. Is your code generator the sort that gives you typesafe accessors for each property?
Created attachment 175326 [details] [review] Add flag to ignore unknown attributes in g_markup_collect_attributes Bug #635641.
Created attachment 175327 [details] [review] Ignore unknown attributes when reading the gsetting schema For forward compatibility, and compatibility with other tools that want to process the schema file, ignore unknown attributes. Bug #635641.
I'd feel a lot better if we were doing this in a way that was actually compatible with XML... I think that implies proper namespace support, and I don't know that we want to go there.
I don't think that ignoring unknown attributes is "incompatible with XML" in any way. Nor do I believe that doing it properly implies namespace support.
Comment on attachment 175326 [details] [review] Add flag to ignore unknown attributes in g_markup_collect_attributes gmarkup now supports this with the commit from bug 665634.
Created attachment 258358 [details] [review] glib-compile-schemas: ignore qualified tags/attrs Ignore qualified (in the XML namespace sense) tags and attributes when compiling GSettings schemas. This will allow people to add custom tags and attributes to their schemas without tripping up the compiler.
Attachment 258358 [details] pushed as 908d7d6 - glib-compile-schemas: ignore qualified tags/attrs