static int medin_doconvert( xml *node, fields *info, xml_convert *c, int nc, int *found ) { int i, fstatus; char *d; *found = 0; if ( !xml_hasdata( node ) ) return BIBL_OK; d = xml_data( node ); for ( i=0; i<nc && *found==0; ++i ) { if ( c[i].a==NULL ) { if ( xml_tagexact( node, c[i].in ) ) { *found = 1; fstatus = fields_add( info, c[i].out, d, c[i].level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } } else { if ( xml_tag_attrib( node, c[i].in, c[i].a, c[i].aval)){ *found = 1; fstatus = fields_add( info, c[i].out, d, c[i].level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } } } return BIBL_OK; }
/* <ArticleTitle>Mechanism and.....</ArticleTitle> */ static int medin_articletitle( xml *node, fields *info ) { int fstatus, status = BIBL_OK; if ( xml_hasdata( node ) ) { fstatus = fields_add( info, "TITLE", xml_data( node ), 0 ); if ( fstatus!=FIELDS_OK ) status = BIBL_ERR_MEMERR; } return status; }
/* <Journal> * <ISSN>0027-8424</ISSN> * <JournalIssue PrintYN="Y"> * <Volume>100</Volume> * <Issue>21</Issue> * <PubDate> * <Year>2003</Year> * <Month>Oct</Month> * <Day>14</Day> * </PubDate> * </Journal Issue> * </Journal> * * or.... * * <Journal> * <ISSN IssnType="Print">0735-0414</ISSN> * <JournalIssue CitedMedium="Print"> * <Volume>38</Volume> * <Issue>1</Issue> * <PubDate> * <MedlineDate>2003 Jan-Feb</MedlineDate> * </PubDate> * </JournalIssue> * <Title>Alcohol and alcoholism (Oxford, Oxfordshire) </Title> * <ISOAbbreviation>Alcohol Alcohol.</ISOAbbreviation> * </Journal> */ static int medin_journal1( xml *node, fields *info ) { xml_convert c[] = { { "Title", NULL, NULL, "TITLE", 1 }, { "ISOAbbreviation", NULL, NULL, "SHORTTITLE", 1 }, { "ISSN", NULL, NULL, "ISSN", 1 }, { "Volume", NULL, NULL, "VOLUME", 1 }, { "Issue", NULL, NULL, "ISSUE", 1 }, { "Year", NULL, NULL, "PARTYEAR", 1 }, { "Month", NULL, NULL, "PARTMONTH", 1 }, { "Day", NULL, NULL, "PARTDAY", 1 }, }; int nc = sizeof( c ) / sizeof( c[0] ), status, found; if ( xml_hasdata( node ) ) { status = medin_doconvert( node, info, c, nc, &found ); if ( status!=BIBL_OK ) return status; if ( !found ) { if ( xml_tagexact( node, "MedlineDate" ) ) { status = medin_medlinedate( info, xml_data( node ), 1 ); if ( status!=BIBL_OK ) return status; } if ( xml_tagexact( node, "Language" ) ) { status = medin_language( node, info, 1 ); if ( status!=BIBL_OK ) return status; } } } if ( node->down ) { status = medin_journal1( node->down, info ); if ( status!=BIBL_OK ) return status; } if ( node->next ) { status = medin_journal1( node->next, info ); if ( status!=BIBL_OK ) return status; } return BIBL_OK; }
static int wordin_reference( xml *node, fields *info ) { int status, ret = BIBL_OK; if ( xml_hasdata( node ) ) { if ( xml_tagexact( node, "b:Tag" ) ) { status = fields_add( info, "REFNUM", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:SourceType" ) ) { } else if ( xml_tagexact( node, "b:City" ) ) { status = fields_add( info, "ADDRESS", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Publisher" ) ) { status = fields_add( info, "PUBLISHER", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Title" ) ) { status = fields_add( info, "TITLE", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:JournalName" ) ) { status = fields_add( info, "TITLE", xml_data( node ), 1 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Volume" ) ) { status = fields_add( info, "VOLUME", xml_data( node ), 1 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Comments" ) ) { status = fields_add( info, "NOTES", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Pages" ) ) { ret = wordin_pages( node, info ); } else if ( xml_tagexact( node, "b:Author" ) && node->down ) { ret = wordin_people( node->down, info, "AUTHOR" ); } else if ( xml_tagexact( node, "b:Editor" ) && node->down ) { ret = wordin_people( node->down, info, "EDITOR" ); } } if ( ret==BIBL_OK && node->next ) wordin_reference( node->next, info ); return ret; }
int xml_tagwithdata( xml *node, char *tag ) { if ( !xml_hasdata( node ) ) return 0; return xml_tagexact( node, tag ); }