A draft for a standard for desktop configuration

Philip Van Hoof spam at pvanhoof.be
Sun Sep 25 14:55:43 EEST 2005


On Sat, 2005-09-24 at 13:50 +0100, Jamie McCracken wrote:
> Philip Van Hoof wrote:
> > 
> > I'm open for suggestions.

I'm still open for suggestions ;-). I adjusted both the DTD and the
sample so that you can see what I mean.

The alias is only unique in one root namespace. The types.dtd (which you
can find in cvs) therefore has the same <node/> construction (you have
to re-create the namespace in XML).

The real attribute is an enumeration of simple, list or enum. A simple
value is or a integer or a string or a double or a boolean. An enum is
non-list type with a list of predefined possible values. A list can be a
homogeneous or non-homogeneous list of simples, lists or enums. The
maximum recursion level of a list is 32 (but you "are" doing things very
wrong if you need that much levels of recursion).

The format attribute is an enumeration of integer, string, double,
boolean or non-homogeneous.

The href attribute might still be wrong (does not specify how to achieve
uniqueness and how to target one specific type in a types.dtd instance
with multiple types), but I'm thinking about making it possible to
define types outside of a ".schemas" file (make it reusable, cascading).

The Min and max elements specify a minimum and maximum (regular
expressions aren't possible, I might add this later if requested).

The default element can be used to specify defaults. For a list with n
default items you need to define n default elements (nested in a root
default element). This works both with homogeneous and non-homogeneous
lists. For non-homogeneous lists, the amount of default elements should
match the amount of type elements (of course).

The maximum size of a path is 8000 characters. So the maximum amount of
characters in the name attributes of the node elements shouldn't grow
larger than 8000 characters plus the amount of components used. 8000 is
an undecided number at this moment (I just decided wile typing this
e-mail :p, what I'm trying to say is that this is indeed specifiable).

I haven't figured out how to correctly specify the possibility to
translate a description. Gettext is nice but might not be platform
independent. Introducing it here might trojan the specification with
something that can be a problem later. I might be wrong here (and can
use your help).

This is the current DTD

------------------------------------------------------------------------------------

<!ENTITY % URI "CDATA">

<!ELEMENT schemas (node)*>

<!ELEMENT node (node*|schema*)>
  <!ATTLIST node name CDATA #REQUIRED>

<!ELEMENT schema (type,default?,description*)>
  <!ATTLIST schema prefname CDATA #IMPLIED>

<!ELEMENT type ((min,max)?,(enum|list)?)>
  <!ATTLIST type alias CDATA #IMPLIED>
  <!ATTLIST type real (simple|list|enum) #REQUIRED>
  <!ATTLIST type format (integer|string|double|boolean|non-homogeneous) #REQUIRED>
  <!ATTLIST type href %URI; #IMPLIED>

<!ELEMENT min (#PCDATA)>
<!ELEMENT max (#PCDATA)>

<!ELEMENT enum (choice+)>
<!ELEMENT choice (#PCDATA)>
<!ELEMENT list (type+)>

<!ELEMENT default (#PCDATA|default)*>
  <!ATTLIST default alias CDATA #IMPLIED>

<!-- This part it still wrong 
<!ELEMENT description ANY>
  <!ATTLIST description xml:lang CDATA #REQUIRED>
  <!ATTLIST description href %URI; #REQUIRED>
-->

------------------------------------------------------------------------------------


This is a sample

------------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE schema PUBLIC "-//freedesktop//DTD configuration schema 1.0//EN" 
"http://www.freedesktop.org/standards/configuration/1.0/schema.dtd">

<schemas>

 <!-- so this is for "/sample_namespace/sample_application/prefs/*" -->
 <node name="sample_namespace"><node name="sample_application"><node name="prefs">

  <!-- Samples of simple types -->

  <!-- string -->
  <schema prefname="my_string">
    <type real="simple" format="string"/>
    <default>Default string</default>
  </schema>

  <!-- integer -->
  <schema prefname="my_integer">
    <type real="simple" format="integer"/>
    <default>20</default>
   </schema>

  <!-- double -->
  <schema prefname="my_double">
    <type real="simple" format="double"/>
    <default>20.99</default>
  </schema>

 <!-- boolean -->
  <schema prefname="my_boolean">
    <type real="simple" format="boolean"/>
    <default>False</default>
  </schema>

  <!-- Samples of simple lists, unlimited in length -->
  <schema prefname="answers">
    <type real="list" format="boolean"/>
  </schema>
  <schema prefname="people">
    <type real="list" format="string"/>
  </schema>
  <schema prefname="maxima">
    <type real="list" format="integer">
	<min>0</min><max>100</max>
    </type>
  </schema>
  <schema prefname="grades">
    <type real="list" format="double"/>
  </schema>

  <!-- Samples of enum types -->
  <schema prefname="when_will_it_happen">
    <type real="enum" format="string">
	<enum>
		<choice>It will happen today</choice>
		<choice>It will happen tomorrow</choice>
		<choice>It will happen this week</choice>
		<choice>It will not happen</choice>
	</enum>
    </type>
    <default>It will not happen</default>
  </schema>

  <!-- Samples of complex types -->

  <!-- Homogeneous: A rectangle -->
  <schema prefname="my_rect">
    <type alias="rect" real="list" format="integer">
     <list>
	<type alias="x1" real="simple" format="integer"/>
	<type alias="x2" real="simple" format="integer"/>
	<type alias="y1" real="simple" format="integer"/>
	<type alias="y2" real="simple" format="integer"/>
     </list>
    </type>
    <default>
	<default alias="x1">10</default>
	<default alias="x2">20</default>
	<default alias="y1">10</default>
	<default alias="y2">40</default>
    </default>
  </schema>

  <!-- A color -->
  <schema prefname="my_color">
     <type alias="color" real="list" format="integer">
      <list>
	<type alias="R" real="simple" format="integer">
		<min>0</min><max>255</max>
	</type>
	<type alias="G" real="simple" format="integer">
		<min>0</min><max>255</max>
	</type>
	<type alias="B" real="simple" format="integer">
		<min>0</min><max>255</max>
	</type>
     </list>
    </type>
    <default>
	<default alias="R">10</default>
	<default alias="G">20</default>
	<default alias="B">10</default>
    </default>
  </schema>

  <!-- Non-homogeneous: Font -->
  <schema prefname="my_font">
     <type alias="font" real="list" format="non-homogeneous">
      <list>
	<type alias="name" real="simple" format="string"/>
	<type alias="size" real="simple" format="integer">
		<min>6</min><max>32</max>
	</type>
      </list>
     </type>
    <default>
	<default alias="name">Arial</default>
	<default alias="size">8</default>
     </default>
  </schema>

 </node></node></node>
</schemas>

------------------------------------------------------------------------------------



-- 
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be




More information about the xdg mailing list