; docformat = 'rst' ; ; NAME: ; readBiblioXML ; PURPOSE: ; Read a list of bibliographic references from NASA/Ads XML output. ; ;+ ; :Description: ; Read a list of bibliographic references from NASA/Ads XML output. ; ; :Categories: ; Bibliography ; ; :Params: ; file: in, required, type=string ; Path to a local XML file with NASA/Ads bibliography entries. ; ; :Keywords: ; refereed: in, optional, type=boolean, default=0 ; The input file contains refereed entries. ; invited: in, optional, type=boolean, default=0 ; The input file contains invited talk entries. ; contributed: in, optional, type=boolean, default=0 ; The input file contains contributed talk entries. ; citations: in, optional, type=boolean, default=0 ; The input file contains citation count. ; ; :Returns: A structure with the bibliographic entries. Fields are:: ; type : Type of entry (refereed|invited|contributed|citations) ; ads : Ads Unique Identifyer ; id : Unique Id ; year : Year of publication ; month : Month of publication ; journal : Journal full name ; abbrev : Journal abbreviation ; volume : Volume ; issue : Issue ; page : Article pages ; title : Article title ; first : First author family name ; doi : Article DOI ; authors : Full list of authors ; ; :Examples: ; ; :Uses: ; read_xml ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in October 2015, B. Carry (OCA) ;- function readBiblioXML, file, refereed=refereed, contributed=contributed, $ invited=invited, citations=citations COMPILE_OPT hidden, idl2 ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--I.1-- Verify Input Syntax ---------------------------------------------------------- if not keyword_set(file) then begin message, /IOERROR, 'Syntax error: bib = readBiblioXML( file )' return, -1 endif ;--I.2-- Test File for Reading -------------------------------------------------------- if not file_test(file,/read) then begin message, /IOERROR, 'Bibliography file cannot be found: '+strtrim(file,2) return, -2 endif ;--I.3-- Type of Entries -------------------------------------------------------------- if not keyword_set(refereed) and $ not keyword_set(contributed) and $ not keyword_set(invited) and $ not keyword_set(citations) then citations=1 refType = string(keyword_set(refereed) ,format='(I1)')+$ string(keyword_set(contributed),format='(I1)')+$ string(keyword_set(invited) ,format='(I1)')+$ string(keyword_set(citations) ,format='(I1)') ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read the Bibliographic Reference File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Blind Read of the File ------------------------------------------------------- spawn, 'wc -l '+file, wcOut split=strSplit(wcOut,' ',/Extract) if strCmp(split[0],'0') then return, -4 info = read_xml(file) nbBib = round(float(info.records.selected)) if nbBib eq 0 then return, 0 ;--II.2-- Build Output Structure ------------------------------------------------------- empty={type:'', ads:'', id:'', year:0, month:'', $ journal:'', abbrev:'', volume:0, issue:'', page:'', $ title:'', first:'', doi: '', $ authors:ptr_new()} bib = replicate(empty, nbBib) ;--II.3-- Fill Output Structure -------------------------------------------------------- tagLag=6 kIn=0 for kBib=0, nbBib-1 do begin ;--II.3.1-- Avoid Pathetic Double Tags ------------------------------------------------- nbOccur = n_elements( info.records.(kIn+tagLag) ) for kOccur=0, nbOccur-1 do begin ;--II.3.1-- Simple NASA/Ads Tags ------------------------------------------------------- bib[kBib].ads = info.records.(kIn+tagLag)[kOccur].bibCode[0]._TEXT split=strSplit( bib[kBib].ads, '&', /Extract, count=nbField ) if nbField gt 1 then begin t = split[0] for kF=1, nbField-1 do t+='%26'+split[kF] bib[kBib].ads = t endif bib[kBib].title = info.records.(kIn+tagLag)[kOccur].title[0]._TEXT if tag_exist(info.records.(kIn+tagLag), 'doi') then $ bib[kBib].DOI = info.records.(kIn+tagLag)[kOccur].doi[0]._TEXT case refType of ;--II.3.2-- Journal Information -------------------------------------------------------- '1000': begin bib[kBib].type = 'refereed' ;--II.3.2/A-- Overall Solution for Journal & Abbreviation journal=info.records.(kIn+tagLag)[kOccur].journal[0]._TEXT split=strsplit(journal,',',/extract, count=nbField) volId=1 bib[kBib].journal= split[0] bib[kBib].abbrev = split[0] ;--II.3.2/B-- Pathetic Cases proceed=1 case split[0] of 'Earth': begin bib[kBib].journal= 'Earth, Moon, and Planets' bib[kBib].abbrev = 'EM&P' volId=3 end 'Astronomy and Astrophysics': bib[kBib].abbrev = 'A&A' 'Astronomy & Astrophysics': bib[kBib].abbrev = 'A&A' 'Astronomische Nachrichten': bib[kBib].abbrev = 'AN' 'The Astronomical Journal': bib[kBib].abbrev = 'AJ' 'The Astrophysical Journal': bib[kBib].abbrev = 'ApJ' 'Experimental Astronomy': bib[kBib].abbrev = 'ExA' 'Journal of Geophysical Research': begin volId=1 bib[kBib].abbrev = 'JGR' end 'Monthly Notices of the Royal Astronomical Society': bib[kBib].abbrev = 'MNRAS' 'Planetary and Space Science': bib[kBib].abbrev = 'P&SS' 'Proceedings of the IERS Workshop on the Implementation of the New IAU Resolutions. Observatoire de Paris': begin sub=strsplit( split[12], '.',/extract) bib[kBib].year = sub[0] proceed=0 end 'NASA Planetary Data System': proceed=0 else: begin sub = strSplit( split[0], ':', /Extract ) if strCmp(sub[0],'eprint arXiv') then proceed=0 end endcase if proceed eq 1 then begin ;--II.3.2/C-- Volume Number sub=strsplit( split[volId],'. ',/extract) bib[kBib].volume = round(float(sub[1])) ;--II.3.2/D-- Issue Number issueId=volId+1 pageId =volId+1 sub=strsplit( split[issueId],'. ',/extract) if strcmp(sub[0],'Issue') then begin bib[kBib].issue = strtrim(sub[1],2) pageId++ endif ;--II.3.2/E-- Pages Information sub=strsplit( split[pageId],'. ',/extract) if strcmp(sub[0],'article') then bib[kBib].page = sub[2] if strcmp(sub[0],'p') or $ strcmp(sub[0],'pp') or $ strcmp(sub[0],'CiteID') or $ strcmp(sub[0],'id') then begin bib[kBib].page = sub[1] endif else begin pageId++ sub=strsplit( split[pageId],'. ',/extract) if strcmp(sub[0],'p') or $ strcmp(sub[0],'pp') or $ strcmp(sub[0],'id') then begin bib[kBib].page = sub[1] endif endelse endif end ;--End of II.3.2-- Journal Information ;--II.3.3-- Conference Information ----------------------------------------------------- '0100': begin bib[kBib].type = 'contributed' ;--II.3.3/A-- Overall Solution for Conferences & Abbrevation conf=info.records.(kIn+tagLag)[kOccur].journal[0]._TEXT split=strSplit(conf,',',/extract, count=nbField) if nbField gt 1 then begin volId=1 bib[kBib].journal= split[0]+','+split[1] bib[kBib].abbrev = split[0] sub=strSplit( split[1], ' ',/extract ) case split[0] of 'American Astronomical Society': begin bib[kBib].abbrev = 'AAS_'+sub[0] bib[kBib].volume = round(float(strmid(sub[2],1,10))) end 'IAU General Assembly': begin bib[kBib].abbrev = 'IAU_GA' bib[kBib].volume = round(float(strmid(sub[1],1,10))) end 'Minor Planet Electronic Circ.': begin bib[kBib].abbrev = 'MPEC' bib[kBib].journal = split[0] bib[kBib].volume = round(float(strmid(sub[1],1,10))) end 'Minor Planet Circular': begin bib[kBib].abbrev = 'MPC' bib[kBib].journal = split[0] end 'IAU Circ.': begin bib[kBib].abbrev = 'IAUC' bib[kBib].journal = split[0] if valid_num(split[1]) then bib[kBib].volume = round(float(split[1])) $ else bib[kBib].volume = round(float(sub[1])) end 'Asteroids': begin bib[kBib].abbrev = 'ACM' bib[kBib].journal = 'Asteroids, Comets, Meteors' ; +split[3] end 'Central Bureau Electronic Telegrams': begin bib[kBib].abbrev = 'CBET' bib[kBib].journal = split[0] bib[kBib].volume = round(float(sub[1])) end 'American Geophysical Union': begin bib[kBib].abbrev = 'AGU' bib[kBib].journal = split[0] bib[kBib].volume = round(float(sub[2])) end 'The Messenger': begin bib[kBib].abbrev = 'Messenger' bib[kBib].journal = split[0] bib[kBib].volume = round(float(strMid(split[1],5,4))) end 'Solar System Science Before and After Gaia': bib[kBib].abbrev = 'Gaia' 'Proceedings of the workshop "Orbital Couples: Pas de Deux in the Solar System and the Milky Way". Held at the Observatoire de Paris': bib[kBib].abbrev = 'OCPD' 'Workshop on Planetesimal Formation and Differentiation': bib[kBib].abbrev = 'PFD' 'Resolving The Future Of Astronomy With Long-Baseline Interferometry Proceedings of a conference held 28-31 March 2011': bib[kBib].abbrev = 'ASPC' 'Proceedings of the Journes 2013 "Systmes de rfrence spatio-temporels": Scientific developments from highly accurate space-time reference systems': bib[kBib].abbrev = 'SRST' 'Living Together: Planets': bib[kBib].abbrev = 'ASP' ; '': bib[kBib].abbrev = 'PFD' else: begin if strCmp(strMid(split[0],5,5),'Lunar') then begin bib[kBib].abbrev = 'LPSC' bib[kBib].journal = split[0] bib[kBib].volume = round(float(strMid(split[0],0,2))) endif if strCmp(strMid(split[0],0,4),'SF2A') then begin bib[kBib].abbrev = 'SF2A' bib[kBib].journal = split[0] endif if strCmp(strMid(split[0],0,12),'Gaia-FUN-SSO') then begin bib[kBib].abbrev = 'GFS' bib[kBib].journal = split[0] endif if strCmp(strMid(split[0],0,22),'Gaia follow-up network') then begin bib[kBib].abbrev = 'GFS' bib[kBib].journal = split[0] endif if strCmp(strMid(split[0],0,35),'European Planetary Science Congress') then begin bib[kBib].abbrev = 'EPSC' bib[kBib].journal = split[0] endif if strCmp(strMid(split[0],0,8),'EPSC-DPS') then begin bib[kBib].abbrev = 'AAS_DPS' endif if strCmp(strMid(split[0],5,6),'COSPAR') then begin bib[kBib].abbrev = 'COSPAR' bib[kBib].journal = 'COSPAR' bib[kBib].volume = round(floaT(strMid(split[0],0,2))) endif end endcase endif else print, conf end ;--End of II.3.3-- Conference Information else: endcase ;--II.3.4-- Author Information --------------------------------------------------------- if tag_exist(info.records.(kIn+tagLag), 'author') then begin ;--II.3.4/A-- First Author Surname first = info.records.(kIn+tagLag)[kOccur].author[0]._TEXT split=strsplit(first,',',/extract) bib[kBib].first = split[0] ;--II.3.4/B-- Full list of co-Authors nbAuthor = n_elements(info.records.(kIn+tagLag)[kOccur].author) bib[kBib].authors = ptr_new(/allocate_heap) *bib[kBib].authors = strarr(nbAuthor) for kAuthor=0, nbAuthor-1 do $ (*bib[kBib].authors)[kAuthor] = info.records.(kIn+tagLag)[kOccur].author[kAuthor]._TEXT endif ;--II.3.5-- Parution date -------------------------------------------------------------- bib[kBib].year = round(float(strmid(info.records.(kIn+tagLag)[kOccur].pubDate[0]._TEXT,4,4))) bib[kBib].month = strmid(info.records.(kIn+tagLag)[kOccur].pubDate[0]._TEXT,0,3) ;--II.3.6-- Article Unique ID (YYYY-JOURNAL-VOL-NAME) ---------------------------------- bib[kBib].id = string(bib[kBib].year,format='(I4)')+'-'+bib[kBib].abbrev+'-'+$% strtrim(string(bib[kBib].volume),2)+'-'+bib[kBib].first ;--II.3.7-- Article Type --------------------------------------------------------------- if keyword_set(invited) then bib[kBib].type = 'invited' if keyword_set(citations) then begin bib[kBib].type = 'citations' bib[kBib].abbrev = 'na' endif kBib++ endfor kBib-- kIn++ endfor bad = where( strCmp(bib.abbrev, ''), comp=valid ) bib=bib[valid] return, bib end