Re: XML MIME type recognition



David Nečas wrote:
> Hi, I cannot get a XML-based format (named generically *.xml,
> unfortunately) recognized by nautilus, no matter what I do.

I couldn't solve this problem yet, but perhaps the information I supply
in this e-mail can help you along.

> <mime-type type="application/x-spml-spm">
>   <comment>SPML data</comment>
>   <magic priority="80">
>     <match type="string" offset="0" value="&lt;?xml">
>       <match type="string" offset="20:60" value="&lt;SPML"/>
>     </match>
>   </magic>
> </mime-type>
> 
> 
> I simply cannot convince nautilus to report XML files as something
> different than application/xml.  Well, unless I include
> 
>   <glob pattern="*.xml/>
> 

It seems application/xml doesn't have a glob associated it with by
default. I've never done anything with the mime database or mime types,
so I couldn't even figure out where the mimetype for XML is supposedly
defined. However, note the following:

/usr/local/share/mime/Overrides.xml (note the redefinition for
application/xml, also note the sub-class-of which doesn't really matter
in this case but I guess it's good to do anwyays):

<?xml version='1.0' encoding='utf-8'?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info";>
	<mime-type type="application/xml">
	  <sub-class-of type="text/plain"/>
	  <glob pattern="*.xml"/>
	</mime-type>
	<mime-type type="application/x-spml-spm">
	  <sub-class-of type="application/xml"/>
	  <comment>SPML data</comment>
	  <glob pattern="*.xml"/>
	  <magic priority="80">
	    <match type="string" offset="0" value="&lt;?xml">
	      <match type="string" offset="20:60" value="&lt;SPML"/>
	    </match>
	  </magic>
	</mime-type>
</mime-info>

sudo update-mime-database /usr/local/share/mime/

Then with an spml-xml-file.xml with content:

<?xml version="1.0" encoding="UTF-8"?>
<xml>
<SPML></SPML>
</xml>

$ gvfs-info normal-xml-file.xml spml-xml-file.xml | grep type
type: regular
  standard::type: 1
  standard::content-type: application/xml
  standard::fast-content-type: application/xml
type: regular
  standard::type: 1
  standard::content-type: application/x-spml-spm
  standard::fast-content-type: application/xml

Resources:

http://library.gnome.org/admin/system-admin-guide/unstable/mimetypes-modifying.html.en#mimetypes-overrides-xml
http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-0.11.html

Best regards,

Bruce

Attachment: signature.asc
Description: OpenPGP digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]