MIME subclasses

Thomas Leonard tal00r at ecs.soton.ac.uk
Tue Sep 30 17:52:54 EEST 2003


While thinking about the syntax for subclassing MIME types
(application/x-python > text/plain > application/octet-stream) some more,
it occurred to me that a syntax already exists for this.

We'd just need a few syntactical changes to the source XML
(update-mime-database can continue to handle the old format too, of
course).

So this:

<mime-info>
  <mime-type type="application/andrew-inset">
    <comment>Andrew Toolkit inset</comment>
    <comment xml:lang="az">Andrew Toolkit inset</comment>
    <comment xml:lang="ca">sagnia Andrew Toolkit</comment>
    ...
    <glob pattern="*.ez"/>
  </mime-type>
  ...

becomes:

<rdf:RDF>
  <mime-type rdf:ID="application/andrew-inset">
    <comment>Andrew Toolkit inset</comment>
    <comment xml:lang="az">Andrew Toolkit inset</comment>
    <comment xml:lang="ca">sagnia Andrew Toolkit</comment>
    ...
    <match-rules>
      <glob pattern="*.ez"/>
    </match-rules>
  </mime-type>
  ...

With appropriate default attributes set in the DTD, eg:
  <!ATTLIST match-rules
  	rdf:parseType CDATA #FIXED "Literal">

The advantage of this is that we get to borrow RDFS's subclassing syntax,
eg:

  <mime-type rdf:ID="application/andrew-inset">
    <rdfs:subClassOf rdf:resource="#application/octet-stream"/>
  </mime-type>

In fact, an RDF aware program wouldn't even have to add any code to
support this. It could just query (eg):

  <mime:application/andrew-inset>  <desktop:has-handler>  <?>

and it would get a list of handlers for application/octet-stream too.

Or something. Anyway:

- Old and new source formats can both be read by update-mime-database.
- Output creates the same .xml files as before.
- We get a syntax for subclassing and aliases.
- RDF-aware programs/libraries can handle it all automatically, or
  programs can continue doing things manually.

As for output, whatever happens we will continue creating all the .xml
files. We can then do one of these things:

- Put the rdfs:subClassOf elements in the .xml files with everything else.
  The result isn't quite valid RDF, but it's easily converted (ie, pretend
  there's an <rdf:RDF> around it).

- Create .rdf files next to the .xml files with the extra bits.

- Dump all the RDF triples into the RDF binary DB format of the day, for
  fast access (/share/mime/compiled.db). Let the RDF people worry about
  it.

Thoughts?


-- 
Thomas Leonard			http://rox.sourceforge.net
tal00r at ecs.soton.ac.uk	tal197 at users.sourceforge.net
GPG: 9242 9807 C985 3C07 44A6  8B9A AE07 8280 59A5 3CC1



More information about the xdg mailing list