Revision: 29202 http://sourceforge.net/p/bibdesk/svn/29202 Author: hofman Date: 2025-04-26 15:01:56 +0000 (Sat, 26 Apr 2025) Log Message: ----------- get string type for record from record and options
Modified Paths: -------------- trunk/bibdesk/BDSKSRUGroupServer.m Modified: trunk/bibdesk/BDSKSRUGroupServer.m =================================================================== --- trunk/bibdesk/BDSKSRUGroupServer.m 2025-04-26 14:33:20 UTC (rev 29201) +++ trunk/bibdesk/BDSKSRUGroupServer.m 2025-04-26 15:01:56 UTC (rev 29202) @@ -191,6 +191,25 @@ } } +- (BDSKStringType)stringTypeForRecordString:(NSString *)string { + NSString *recordSyntax = [serverInfo recordSyntax]; + BDSKStringType stringType = BDSKStringTypeUnknown; + if(recordSyntax == nil || [recordSyntax isEqualToString:@"marcxml"]) { + stringType = BDSKStringTypeMARC; + if ([BDSKStringParser canParseString:string ofType:stringType] == NO) + stringType = BDSKStringTypeDublinCore; + } else if([recordSyntax isEqualToString:@"dc"]) { + stringType = BDSKStringTypeDublinCore; + if ([BDSKStringParser canParseString:string ofType:stringType] == NO) + stringType = BDSKStringTypeMARC; + } else if([recordSyntax isEqualToString:@"mods"]) { + stringType = BDSKStringTypeMODS; + } + if (NO == [BDSKStringParser canParseString:string ofType:stringType]) + stringType = [string contentStringType]; + return stringType; +} + - (void)fetch { if ([self numberOfAvailableResults] <= [self numberOfFetchedResults]) { downloadState = BDSKIdleState; @@ -284,20 +303,12 @@ NSMutableArray *pubs = [NSMutableArray array]; for (NSXMLNode *node in records) { - NSString *string = [[[node children] firstObject] XMLString] ?: @""; - BibItem *pub = nil; - - if ([BDSKMARCParser canParseString:string]) { - pub = [[BDSKMARCParser itemsFromString:string error:NULL] firstObject]; - } else { - BDSKStringType stringType = [string contentStringType]; - if (stringType != BDSKStringTypeUnknown) - pub = [[BDSKStringParser itemsFromString:string ofType:stringType error:NULL] firstObject]; - } + NSString *record = [[[node children] firstObject] XMLString] ?: @""; + BDSKStringType stringType = [self stringTypeForRecordString:record]; + BibItem *pub = [[BDSKStringParser itemsFromString:record ofType:stringType error:NULL] firstObject]; if (pub == nil) - pub = [[BibItem alloc] initWithType:BDSKBookString citeKey:nil pubFields:@{BDSKAnnoteString: string}]; + pub = [[BibItem alloc] initWithType:BDSKBookString citeKey:nil pubFields:@{BDSKAnnoteString:record}]; [pubs addObject:pub]; - } // set before addPublications: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit