Changeset 21 for trunk/bibopa.sh


Ignore:
Timestamp:
06/21/07 13:32:01 (17 years ago)
Author:
pinsard
Message:

change encoding of DOI in bibliography XML file. cf. ticket#14

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bibopa.sh

    r15 r21  
    2323#    Short Rains: A CGCM Study</title> 
    2424#    <publishername>J. Climate</publishername> 
    25 #    <bibliomisc role="doi">doi</bibliomisc> 
     25#    <biblioid class="doi">doi</bibliomisc> 
    2626#    <bibliomisc role="pseudoref">In press.</bibliomisc> 
    2727#    <bibliomisc role="internalref">from  
     
    4444# ++ gestion des id existants (cf à la fin) 
    4545# ++ option debug 
     46# fplod 2007-06-20T17:18:02Z aedon.locean-ipsl.upmc.fr (Darwin) 
     47# <bibliomisc role="id"> replace by <biblioid class="doi"> 
    4648# smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) 
    4749# Add journals 
     
    237239totlines=$( wc -l ${fileraw_strict} | awk '{print $1}' ) 
    238240l=1 
    239 while [ $l -le $totlines  ] 
     241while [ ${l} -le ${totlines}  ] 
    240242do 
    241243# extract one line 
    242244 
    243245  line=$( sed -n ${l}p ${fileraw_strict} ) 
    244   orgline=$( echo $line | sed -e "s/--/- -/g" ) 
    245   line=$( echo $line | sed -e "s/</\&lt;/g" -e "s/>/\&gt;/g" ) 
     246  orgline=$( echo ${line} | sed -e "s/--/- -/g" ) 
     247  line=$( echo ${line} | sed -e "s/</\&lt;/g" -e "s/>/\&gt;/g" ) 
    246248# before the first : 
    247249  tmp=${line%%:*} 
     
    249251  auths=${tmp%,*}, 
    250252# supress and 
    251   auths=$( echo "$auths" | sed -e "s/ and //g" ) 
     253  auths=$( echo "${auths}" | sed -e "s/ and //g" ) 
    252254# after the last , 
    253255  year=${tmp##*,} 
    254   year=$( rmbl "$year" ) 
     256  year=$( rmbl "${year}" ) 
    255257## first author before the first ., 
    256258  first=${auths%%.,*}. 
    257259# its firstname after the last , 
    258260  firstfn=${first##*,} 
    259   firstfn=$( rmbl "$firstfn" ) 
     261  firstfn=$( rmbl "${firstfn}" ) 
    260262# its surname ; before the first , 
    261263  firstsn=${first%%,*} 
    262   firstsn=$( rmbl "$firstsn" ) 
     264  firstsn=$( rmbl "${firstsn}" ) 
    263265## ref id 
    264   refid=$( echo $firstsn | tr "[:upper:]" "[:lower:]" | tr -s " " "_"  | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )$year 
    265   num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" $fileou ) 
    266   num=$(( $num + 1 )) 
    267   [ $num -le 9 ] && num=0$num  
    268   refid=${refid}_$num 
    269    
    270           cat <<EOF >> $fileou 
     266  refid=$( echo ${firstsn} | tr "[:upper:]" "[:lower:]" | tr -s " " "_"  | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )${year} 
     267  num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" ${fileou} ) 
     268  num=$(( ${num} + 1 )) 
     269  [ ${num} -le 9 ] && num=0${num}  
     270  refid=${refid}_${num} 
     271   
     272          cat <<EOF >> ${fileou} 
    271273<biblioentry id="${refid}"> 
    272274  <!-- date 
     
    285287  next=${auths##*${previous}} 
    286288# while the next author is not empty 
    287   while [  "$next" != "" ] 
     289  while [  "${next}" != "" ] 
    288290    do 
    289291# get the first next author; before the first , 
     
    291293# its surname ; after the last . 
    292294    nextsn=${next##*.} 
    293     nextsn=$( rmbl "$nextsn" ) 
     295    nextsn=$( rmbl "${nextsn}" ) 
    294296# its firstname ; before the last . 
    295297    nextfn=${next%.*}. 
    296     nextfn=$( rmbl "$nextfn" ) 
     298    nextfn=$( rmbl "${nextfn}" ) 
    297299# 
    298300    echo "    <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} 
     
    301303     
    302304  done 
    303   echo "  </authorgroup>"  >> $fileou 
     305  echo "  </authorgroup>"  >> ${fileou} 
    304306   
    305307# end of the line ; after the first : 
     
    312314  while [[ $j -le $jlistsize && "${jfound}" == "" ]] 
    313315    do 
    314     ok=$( echo $endline | grep -ci "${jlist[j]} *," )  
     316    ok=$( echo ${endline} | grep -ci "${jlist[j]} *," )  
    315317    [ $ok -eq 1 ] && jfound="${jlist[j]}" 
    316318    j=$(( $j + 1 )) 
     
    318320  if [ "$jfound" == "" ] 
    319321      then 
    320       echo ERROR Journal not found 
    321       echo $endline 
     322      echo "ERROR Journal not found" 
     323      echo "${endline}" 
    322324      exit 
    323325  fi 
     
    325327# before the first : 
    326328  title=${endline%%${jfound}*} 
    327   title=$( cleanname "$title" ) 
    328   echo "  <title>${title}</title>" >> $fileou 
     329  title=$( cleanname "${title}" ) 
     330  echo "  <title>${title}</title>" >> ${fileou} 
    329331## end  
    330332## end of the line ; after the first ${jfound} 
    331333  endline=${endline#*${jfound}} 
    332   endline=$( cleanname "$endline" ) 
     334  endline=$( cleanname "${endline}" ) 
    333335## doi 
    334   endline=$( echo $endline | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) 
    335   ok=$( echo $endline | grep -ic "doi:" ) 
     336  endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) 
     337  ok=$( echo ${endline} | grep -ic "doi:" ) 
    336338  if [ $ok -eq 1 ] 
    337339      then 
    338340      doi=${endline##*doi:} 
    339       echo "  <bibliomisc role=\"doi\">${doi}</bibliomisc>" >> $fileou 
     341      echo "  <biblioid class=\"doi\">${doi}</biblioid>" >> ${fileou} 
    340342      endline=${endline%doi:*} 
    341       endline=$( cleanname "$endline" ) 
     343      endline=$( cleanname "${endline}" ) 
    342344  else 
    343       echo non doi: $line 
     345      echo "non doi: ${line}" 
    344346  fi 
    345   num=$( echo $endline |  tr -dc "," | wc -c ) 
    346   case $num in 
     347  num=$( echo ${endline} |  tr -dc "," | wc -c ) 
     348  case ${num} in 
    347349      1)  
    348 ### echo $num: ${endline} 
     350### echo ${num}: ${endline} 
    349351          vol=${endline%,*} 
    350           vol=$( cleanname "$vol" ) 
     352          vol=$( cleanname "${vol}" ) 
    351353          pag=${endline##*,}  
    352           pag=$( cleanname "$pag" ) 
    353           cat <<EOF >> $fileou 
     354          pag=$( cleanname "${pag}" ) 
     355          cat <<EOF >> ${fileou} 
    354356  <biblioset relation="journal"> 
    355357    <title>${jfound}</title> 
     
    361363      2)  
    362364          vol=${endline%,*} 
    363           vol=$( cleanname "$vol" ) 
     365          vol=$( cleanname "${vol}" ) 
    364366          iss=${vol##*,}  
    365           iss=$( cleanname "$iss" ) 
     367          iss=$( cleanname "${iss}" ) 
    366368          vol=${vol%,*} 
    367           vol=$( cleanname "$vol" ) 
     369          vol=$( cleanname "${vol}" ) 
    368370          pag=${endline##*,}  
    369           pag=$( cleanname "$pag" ) 
    370           cat <<EOF >> $fileou 
     371          pag=$( cleanname "${pag}" ) 
     372          cat <<EOF >> ${fileou} 
    371373  <biblioset role="journal"> 
    372374    <title>${jfound}</title> 
     
    377379      ;; 
    378380      *) 
    379 echo $num: ${endline} 
    380           cat <<EOF >> $fileou 
     381echo ${num}: ${endline} 
     382          cat <<EOF >> ${fileou} 
    381383  <biblioset role="journal"> 
    382384    <title>${jfound}</title> 
     
    388390  esac 
    389391  
    390           cat <<EOF >> $fileou 
     392          cat <<EOF >> ${fileou} 
    391393</biblioentry> 
    392394   
     
    400402   
    401403done 
    402 echo "</bibliography>" >> $fileou 
     404echo "</bibliography>" >> ${fileou} 
    403405 
    404406xsltproc \ 
Note: See TracChangeset for help on using the changeset viewer.