Spotlight Importer Schema Format
For Spotlight to know what attributes an importer supports, the importer 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 file’s metadata, and specifies any custom metadata attributes that your files require.
The Schema.xml File
The schema is specified in an XML schema file named 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> |
Specifying Custom Attributes
Declare attributes for your Spotlight importer 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> |
Specifying the Attributes for a File
There is a single type
element for each file 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 file type. |
A type
element specifies the metadata attributes that it returns in the allattrs
element, separating each name with a space. The allattrs
element should contain all the elements related to your custom file.
The metadata attributes to be displayed for previewing for a file—for example in Finder Get Info window—are listed within the displayattrs
element, separating each name with a space.
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> |
Copyright © 2004, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-08-08