views:

36

answers:

1

I have created a spotlight importer for comic files. The attributes are successfully imported and searchable. The one thing that remains is getting the attributes to display in a file's get info window.

It seems that this should be a simple matter of editing the schema.xml file so the attributes are nested inside displayattrs tags. Unfortunately this does not seem to be working.

I simplified the plugin for testing. The following are all of the important files.

schema.xml

<types>
<type name="cx.c3.cbz-archive">  
    <allattrs>
        kMDItemTitle
        kMDItemAuthors
    </allattrs>
    <displayattrs>
        kMDItemTitle
        kMDItemAuthors
    </displayattrs>
    </type>
<type name="cx.c3.cbr-archive">  
    <allattrs>
        kMDItemTitle
        kMDItemAuthors
        </allattrs>
    <displayattrs>
        kMDItemTitle
        kMDItemAuthors
    </displayattrs>
</type>
</types>

GetMetadataForFile.m

Boolean GetMetadataForFile(void* thisInterface, 
                       CFMutableDictionaryRef attributes, 
                       CFStringRef contentTypeUTI,
                       CFStringRef pathToFile)
{
    NSAutoreleasePool * pool = [NSAutoreleasePool new];
    NSString * file = (NSString *)pathToFile;
    NSArray * authors = [[UKXattrMetadataStore stringForKey: @"com_opencomics_authors" atPath: file traverseLink: NO] componentsSeparatedByString: @","];
    [(NSMutableDictionary *)attributes setObject: authors forKey: (id)kMDItemAuthors];
    NSString * title = [UKXattrMetadataStore stringForKey: @"com_opencomics_title" atPath: file traverseLink: NO];
    [(NSMutableDictionary *)attributes setObject: title forKey: (id)kMDItemTitle];
    [pool release];
    return true;
}
+1  A: 

You seem to be missing a </types> tag. Copy/paste error in writing the question, or is it missing in the XML file, too?

If it's missing in the file, the XML is invalid.

Peter Hosey
Screwed up the stack overflow formatting.I ran mdcheckschema on it during my troubleshooting.
Alexander Rauchfuss