For Spotlight to know what attributes an importer supports, it must provide a schema file. The schema file describes the attributes that the importer populates, describes the attributes that applications should use to provide a preview of the document’s metadata, and specifies any custom metadata attributes that your documents require.
The schema is specified in an XML schema file called schema.xml
within your Spotlight importer bundle.
The following XML fragment shows the general format of the file.
<?xml version="1.0" encoding="UTF-8"?> |
<schema version="1.0" xmlns="http://www.apple.com/metadata" |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
xsi:schemaLocation="http://www.apple.com/metadata |
file:///System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/ |
Resources/MetadataSchema.xsd"> |
<attributes> |
... |
</attributes> |
<types> |
<type name="SUPPORTED_UTI_TYPE"> |
<allattrs> |
... |
</allattrs> |
<displayattrs> |
... |
</displayattrs> |
</type> |
</types> |
</schema> |
Custom attributes for your Spotlight importer are declared as attribute
elements that are children of the attributes
element. The XML attributes for the attribute
element are shown in Table 1.
The following is an example XML fragment for the attributes
element of a schema.
<attributes> |
<attribute name="com_apple_myCocoaDocumentApp_myCustomDocument_notes" multivalued="false" type="CFString"/> |
</attributes> |
There is a single type
element for each document type that your importer can read. The XML attributes for the type
element are shown in Table 2.
Attributes | Description |
---|---|
name | The Uniform Type Identifier declared for the document type. |
A type
element specifies the metadata attributes that it returns in the allattrs
element, separating each name with whitespace. The allattrs
element should contain all the elements related to your custom document.
The metadata attributes to be displayed for previewing for a document—for example in Finder’s Get Info panel—are listed within the displayattrs
element, separating each name with whitespace.
The following is an example XML fragment for a types
element of a schema.
<types> |
<type name="com.apple.mycocoadocumentapp.mycustomdocument"> |
<allattrs> |
com_apple_myCocoaDocumentApp_myCustomDocument_notes |
</allattrs> |
<displayattrs> |
com_apple_myCocoaDocumentApp_myCustomDocument_notes |
</displayattrs> |
</type> |
</types> |
Last updated: 2009-10-11