Exemple #1
0
/* output_genre()
 *
 * <genre authority="marcgt">thesis</genre>
 * <genre>Diploma thesis</genre>
 */
static void
output_genre( fields *f, FILE *outptr, int level )
{
	char *value, *attr, *attrvalue="marcgt";
	int i, n;

	n = fields_num( f );
	for ( i=0; i<n; ++i ) {
		if ( fields_level( f, i ) != level ) continue;
		if ( !fields_match_tag( f, i, "GENRE" ) && !fields_match_tag( f, i, "NGENRE" ) ) continue;
		value = fields_value( f, i, FIELDS_CHRP );
		attr = ( marc_findgenre( value ) == -1 ) ? NULL : "authority";
		output_tag( outptr, lvl2indent(level), "genre", value, TAG_OPENCLOSE, TAG_NEWLINE, attr, attrvalue, NULL );
	}
}
Exemple #2
0
static void
output_jstor( FILE *fp, fields *f )
{
	newstr s;
	int i;
	newstr_init( &s );
	for ( i=0; i<fields_num( f ); ++i ) {
		if ( !fields_match_tag( f, i, "JSTOR" ) ) continue;
		jstor_to_url( f, i, "URL", &s );
		if ( s.len )
			fprintf( fp, "UR  - %s\n", s.data );
	}
	newstr_free( &s );
}
Exemple #3
0
static void
output_jstor( FILE *fp, fields *f )
{
	newstr jstor_url;
	int i, n;

	newstr_init( &jstor_url );

	n = fields_num( f );
	for ( i=0; i<n; ++i ) {
		if ( !fields_match_tag( f, i, "JSTOR" ) ) continue;
		jstor_to_url( f, i, "URL", &jstor_url );
		if ( jstor_url.len )
			fprintf( fp, "%%U %s\n", jstor_url.data );
	}

	newstr_free( &jstor_url );
}
Exemple #4
0
static void
output_arxiv( FILE *fp, fields *f )
{
	newstr arxiv_url;
	int i, n;

	newstr_init( &arxiv_url );

	n = fields_num( f );
	for ( i=0; i<n; ++i ) {
		if ( !fields_match_tag( f, i, "ARXIV" ) ) continue;
		arxiv_to_url( f, i, "URL", &arxiv_url );
		if ( arxiv_url.len )
			fprintf( fp, "%%U %s\n", arxiv_url.data );
	}

	newstr_free( &arxiv_url );
}
Exemple #5
0
static void
output_pmid( FILE *fp, fields *f )
{
	newstr pmid_url;
	int i, n;

	newstr_init( &pmid_url );

	n = fields_num( f );
	for ( i=0; i<n; ++i ) {
		if ( !fields_match_tag( f, i, "PMID" ) ) continue;
		pmid_to_url( f, i, "URL", &pmid_url );
		if ( pmid_url.len )
			fprintf( fp, "%%U %s\n", pmid_url.data );
	}

	newstr_free( &pmid_url );
}
Exemple #6
0
static void
output_doi( FILE *fp, fields *f )
{
	newstr doi_url;
	int i, n;

	newstr_init( &doi_url );

	n = fields_num( f );
	for ( i=0; i<n; ++i ) {
		if ( !fields_match_tag( f, i, "DOI" ) ) continue;
		doi_to_url( f, i, "URL", &doi_url );
		if ( doi_url.len )
			fprintf( fp, "%%U %s\n", doi_url.data );
	}

	newstr_free( &doi_url );
}
Exemple #7
0
/* Try to determine type of reference from
 * <genre></genre>
 */
static int
get_type_genre( fields *f, param *p )
{
	match_type match_genres[] = {
		{ "academic journal",          TYPE_ARTICLE },
		{ "article",                   TYPE_ARTICLE },
		{ "journal article",           TYPE_ARTICLE },
		{ "magazine",                  TYPE_MAGARTICLE },
		{ "conference publication",    TYPE_CONF },
		{ "newspaper",                 TYPE_NEWS },
		{ "legislation",               TYPE_STATUTE },
		{ "communication",             TYPE_PCOMM },
		{ "hearing",                   TYPE_HEAR },
		{ "electronic",                TYPE_ELEC },
		{ "legal case and case notes", TYPE_CASE },
		{ "book chapter",              TYPE_INBOOK },
		{ "Ph.D. thesis",              TYPE_PHDTHESIS },
		{ "Masters thesis",            TYPE_MASTERSTHESIS },
		{ "Diploma thesis",            TYPE_DIPLOMATHESIS },
		{ "Doctoral thesis",           TYPE_DOCTORALTHESIS },
		{ "Habilitation thesis",       TYPE_HABILITATIONTHESIS },
		{ "report",                    TYPE_REPORT },
		{ "abstract or summary",       TYPE_ABSTRACT },
		{ "patent",                    TYPE_PATENT },
		{ "unpublished",               TYPE_UNPUBLISHED },
		{ "map",                       TYPE_MAP },
	};
	int nmatch_genres = sizeof( match_genres ) / sizeof( match_genres[0] );
	int type, i, j;
	char *tag, *value;

	type = TYPE_UNKNOWN;

	for ( i=0; i<fields_num( f ); ++i ) {
		if ( !fields_match_tag( f, i, "GENRE" ) &&
		     !fields_match_tag( f, i, "NGENRE" ) )
			continue;
		value = ( char * ) fields_value( f, i, FIELDS_CHRP );
		for ( j=0; j<nmatch_genres; ++j )
			if ( !strcasecmp( match_genres[j].name, value ) )
				type = match_genres[j].type;
		if ( p->verbose ) {
			tag = ( char * ) fields_tag( f, i, FIELDS_CHRP );
			if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
			fprintf( stderr, "Type from tag '%s' data '%s': ", tag, value );
			write_type( stderr, type );
			fprintf( stderr, "\n" );
		}
		if ( type==TYPE_UNKNOWN ) {
			if ( !strcasecmp( value, "periodical" ) )
				type = TYPE_ARTICLE;
			else if ( !strcasecmp( value, "thesis" ) )
				type = TYPE_THESIS;
			else if ( !strcasecmp( value, "book" ) ) {
				if ( fields_level( f, i )==0 ) type=TYPE_BOOK;
				else type=TYPE_INBOOK;
			}
			else if ( !strcasecmp( value, "collection" ) ) {
				if ( fields_level( f, i )==0 ) type=TYPE_BOOK;
				else type=TYPE_INBOOK;
			}
		}

	}

	if ( p->verbose ) {
		if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
		fprintf( stderr, "Type from genre element: " );
		write_type( stderr, type );
		fprintf( stderr, "\n" );
	}

	return type;
}