[rfc] KConfig Schema

Marc Mutz Marc.Mutz at uni-bielefeld.de
Tue Nov 19 15:10:14 GMT 2002


On Tuesday 19 November 2002 12:18, Waldo Bastian wrote:
> On Tuesday 19 November 2002 00:37, Marc Mutz wrote:
<snip>
> > I've hammered together a proposal for a lightweight config item
> > type declaration language that is based on "XML Schema (2):
> > Datatypes", but is not XML.
>
> Great!
>
> Now to be picky, if you don't read these files at runtime (hurray!) I
> rather have them XML and compatible with the files used by GConf as
> far as possible.
<snip>

Problem with XML is the lack of APIs to handle it. XML Schema depends on 
at least XPath and XPointer and nobody implemented this on top of QXML 
yet.

The ideal thing would be to build on XML Schema and let each app author 
write a schma that validates the kconfig/gconf that is is in XML. 
Config dialogs would be described in XForms language, which includes 
enabling/disabling of widgets based on values. XForms processors can 
fill any template XML document with a Schema bound to it.

Perfect reuse of existing tools, everyone can modifiy it without C++ 
knowledge. BUT: It's slow and there are no tools for it yet. It may be 
nice for KDE4/Gnome3, but for now we have to strip it down somehow.

XML Schema is a mighty language and it would be a _very_ hard task to 
write a full schema processor. OTOH, simpleTypes are relatively 
straightforward. You can compare this with the task of implementing 
CSS3 selectors vs. the whole CSS3 spec.

What I have tried to come up with is a language thats
1. easy to learn (b/c app authors have better things to do than learning 
a language just to store their app config)
2. XML Schema oriented (so eventual transition to XML/XMLSchema based 
approaches is straight-forward)
3. easy to parse
4. easy to implement a validator for
5. easy to implement a config file validator on top

I can, of course just make the syntax XML, like

<type name="listOfInt">
  <list basetype="int" />
</type>

Hmm, thinking of it. That might be fun. Here's a declaration for the 
filter sections of KMail (which is almost XML schema):

<configSchema xmlns="http://www.freedesktops.org/configSchema">

<type name="applyOnType">
  <list>
    <type>
      <restriction basetype="token">
        <enumeration value="check-mail"/>
        <enumeration value="manual-filtering"/>
        <enumeration value="sent-mail"/>
      </restriction>
    </type>
  </list>
</type>

<type name="operatorType">
  <restriction basetype="token">
    <enumeration value="and"/>
    <enumeration value="or"/>
  </restriction>
</type>

<type name="intOrString">
  <union basetype="int string"/>
</type>

<group pattern="Filter #\d+">
	<key name="StopProcessingHere" default="true" type="boolean"/>
	<key name="actions" default="0" type="nonNegativeInteger"/>
	<key name="rules" default="0" type="nonNegativeInteger"/>
	<key name="name" default="" type="string"/>
	<key pattern="action-name-\d+" default="" type="token"/>
	<key pattern="action-args-\d+" default="" type="anySimpleType"/>
	<key name="apply-on" default="check-mail,manual-filtering"
	     type="applyOnType"/>
	<key name="operator" default="and" type="operatorType"/>
	<key pattern="contents[A-Z]" default="" type="intOrString"/>
	<!-- anonymous type defined inline: -->
	<key pattern="rule[A-Z]" default="">
		<type><restriction basetype="nonNegativeInteger">
			<maxInclusive value="26"/>
		</restriction></type>
	</key>
	<key pattern="func[A-Z]" default="contains">
		<type><restriction basetype="token">
			<enumeration value="is"/>
			<enumeration value="contains"/>
			<enumeration value="regexp"/>
			<enumeration value="less"/>
			<!-- etc -->
		</restriction></type>
	</key>
</group>

</configSchema>

Marc

-- 
History teaches that grave threats to liberty often come in times of
urgency, when constitutional rights seem too extravagant to endure.
                                  -- Justice Thurgood Marshall, 1989
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021119/800de717/attachment.sig>


More information about the kde-core-devel mailing list