source: trunk/bibopa.sh @ 140

Last change on this file since 140 was 137, checked in by pinsard, 12 years ago

new files tree for docs (to be cont.)

  • Property svn:keywords set to Id
File size: 41.7 KB
Line 
1#!/bin/bash
2#+
3#
4# .. program:: bibopa.sh
5#
6# =========
7# bibopa.sh
8# =========
9#
10# -----------------------------------------------------
11# transform a bibliography file in XML/DocBook 5 format
12# -----------------------------------------------------
13#
14# SYNOPSIS
15# ========
16#
17# ::
18#
19#  $ bibopa.sh -i filein -ti typein -o order -p project -l lang -to typeout
20#
21#
22# DESCRIPTION
23# ===========
24#
25# .. option:: -i   <filein>
26# .. option:: -ti  <typein>
27# .. option:: -o   <order>
28# .. option:: -p   <project>
29# .. option:: -l   <lang>
30# .. option:: -to  <typeout>
31#
32# Each entry in the same input file must follows the same order for authors
33# except the first one.
34#
35# With ``fs`` in option :option:`-o order` you will correctly process raw entry with
36# firstname and surname in this order for authors except the first one.
37#
38# If raw entry uses surname and firstname order, you should use ``sf``.
39#
40# ::
41#
42#    Behera, S. K., J. Luo, S. Masson, S. Rao, S. Gualdi, P. Delecluse, A.
43#    Navarra and T. Yamagata, 2004 : Paramount Impact of the Indian Ocean
44#    Dipole on the East African Short Rains: A CGCM Study, J. Climate, In
45#    press.
46#
47#
48# donnerait
49#
50# ::
51#
52#    <biblioentry xml:id="behara2004">
53#    <authorgroup>
54#    <author><surname>Behera</surname> <firstname>S. K.</firstname> </author>
55#    <author><firstname>J.</firstname> <surname>Luo</surname></author>
56#    <author><firstname>S.</firstname> <surname>Masson</surname></author>
57#    <author><firstname>S.</firstname> <surname>Rao</surname></author>
58#    <author><firstname>S.</firstname> <surname>Gualdi</surname></author>
59#    <author><firstname>P.</firstname> <surname>Delecluse</surname></author>
60#    <author><firstname>A.</firstname> <surname>Navara</surname></author>
61#    <author><firstname>T.</firstname> <surname>Yamagata</surname></author>
62#    </authorgroup>
63#    <date>2004</date>
64#    <title>Paramount Impact of the Indian Ocean Dipole on the East African
65#    Short Rains: A CGCM Study</title>
66#    <publishername>J. Climate</publishername>
67#    <biblioid class="doi">doi</biblioid>
68#    <bibliomisc role="pseudoref">In press.</bibliomisc>
69#    <bibliomisc role="internalref">from
70#    http://www.lodyc.jussieu.fr/~opatlod/NEMO_v1/6_Menu/2_page/index.html
71#    2007-03-29T16:24:31Z fplod by hand</bibliomisc>
72#    </biblioentry>
73#
74#
75# ::
76#
77#   @book{MetReiCoh2004 ,
78#      author    = {Michael Metcalf and
79#              John Reid and Malcolm Cohen},
80#      title     = {Fortran 95/2003 explained},
81#      year      = {2004},
82#      publisher = {Oxford University Press},
83#      edition   = {Third},
84#      ISBN      = {0-19-852693-8},
85#      pages = {434}
86#   }
87#
88#
89# donnerait
90#
91# ::
92#
93#    <biblioentry xml:id="MetReiCoh2004">
94#    <authorgroup>
95#    <author><firstname>Michael</firstname> <surname>Metcalf</surname></author>
96#    <author><firstname>John</firstname> <surname>Reid</surname></author>
97#    <author><firstname>Malcolm</firstname> <surname>Cohen</surname></author>
98#    </authorgroup>
99#    <date>2004}</date>
100#    <title>Fortran 95/2003 explained</title>
101#    <publisher><publishername>Oxford University Press</publishername></publisher>
102#    <biblioid class="isbn">0-19-852693-8</biblioid>
103#    <pagenums>434</pagenums>
104#    <edition>Third</edition>
105#
106#
107# EXAMPLES
108# ========
109#
110# To transform the NEMO bibliography file written in raw format to XML/DocBook::
111#
112#  $ ./bibopa.sh -p birefnemo -i data/biball.txt -ti raw
113#
114#
115# To transform a bibliography file written mailbody format to XML/DocBook::
116#
117#  $ ./bibopa.sh -p bibrefnemo -i data/mail2007-05-10T09:01:56Z -ti mailbody
118#
119#
120# To transform a bibliography file written in bibtex format in french to XML/DocBook::
121#
122#  $ ./bibopa.sh -p polyfortran -i data/petitpolyfp.bib -ti bibtex -l fr
123#
124#
125# To transform the SUPERBIB demo bibliography file written in raw format to XML/DocBook::
126#
127#  $ ./bibopa.sh -p demo1 -i data/bibdemo1.txt -ti raw -l fr
128#
129# Less official but possible:
130#
131# To transform the NEMO bibliography file written in raw format to bibtex::
132#
133#  $ ./bibopa.sh -p nemo -ti raw -to bibtex -i bibnemo.txt
134#
135# SEE ALSO
136# ========
137#
138# :ref:`mailtouser.sh`
139#
140# TODO
141# ====
142#
143# gestion des comments
144#
145# gestion des id existants (cf à la fin)
146#
147# option debug
148#
149# should use iconv instead of recode
150# for portability issue but not found yet the "flat" fonctionnality in
151# iconv
152# tips 20101006 : iconv: //TRANSLIT feature not documented cf.
153# http://www.gnu.org/software/libiconv/documentation/libiconv/iconv_open.3.html
154# not already used because non-standard usage
155#
156# write something in the logfile !
157#
158# handle fully written firstnames like in::
159#
160#  Tsimplis, Michael, Marta Marcos, Jeanne Colin, Samuel Somot, Ananda Pascual, A.G.P. Shaw, 2009 : Sea level variability in the Mediterranean Sea during the 1990s on the basis of two 2d and one 3d model, Journal of Marine Systems, 78, 1, 109-123, doi:10.1016/j.jmarsys.2009.04.003
161#
162#
163# EVOLUTIONS
164# ==========
165#
166# $Id$
167#
168# - fplod 20101006T113902Z aedon.locean-ipsl.upmc.fr (Darwin)
169#
170#   * add "Remote Sensing Env."
171#   * add "Ocean Sciences"
172#   * add "Dynamics of Atmospheres and Oceans"
173#   * add "Comptes Rendus Geoscience"
174#   * add "Marine Pollution Bulletin"
175#   * add "Continental Shelf Research"
176#   * add ""Ocean Sci."
177#   * add "Environmental Fluid Mechanics"
178#   * add "Geochem. Geophys. Geosyst."
179#   * add "Journal of Applied Meteorology and Climatology"
180#   * add "Monthly Weather Review"
181#   * add "High Performance Computing on Vector Systems 2007"
182#   * add "High Performance Computing on Vector Systems 2006"
183#   * add "High Performance Computing in Science and Engineering '08"
184#   * add "Developments in Earth and Environmental Sciences"
185#   * add "Oceanography"
186#
187# - fplod 20101006T100532Z aedon.locean-ipsl.upmc.fr (Darwin)
188#
189#   * bug fix (missplaced EOF)
190#   * replace -t option by -ti
191#   * add -to (typeout) option (by default dbk)
192#   * add bibtex production
193#
194# - fplod 2009-03-13T09:35:42Z aedon.locean-ipsl.upmc.fr (Darwin)
195#
196#   * add "High Performance Computing in Science and Engineering"
197#   * add "Annals of Glaciology"
198#   * add "Journal of Physical Oceanography"
199#
200# - fplod 2009-01-15T10:36:18Z aedon.locean-ipsl.upmc.fr (Darwin)
201#
202#   * add description of ``-o`` option
203#   * add journal "PNAS"
204#   * add journal "Lettre PIGB-PMRC"
205#
206# - fplod 2009-01-14T15:27:48Z aedon.locean-ipsl.upmc.fr (Darwin)
207#
208#   * add journal "Water Resources Research"
209#   * add journal "Climate Research"
210#   * add conf "Colloque du GIS « Climat-Environnement-Sociétés »"
211#   * add journal "Agricultural and Forest Meteorology"
212#   * add conf "VIIth IAHS Scientific Assembly"
213#   * add conf "AGU fall Meeting"
214#   * add journal "Phil. Trans. Roy. Soc. B"
215#   * add journal "Phil. Trans. Roy. Soc. B"
216#   * add conf "4th Alexander Von Humboldt International Conference"
217#   * add journal/conf "??" (Should not be used too much !)
218#   * add journal "Nature Geosciences"
219#   * add journal "International Journal of Climatology"
220#   * add journal "Journal of Hydrology"
221#   * add journal "Revue de l'Énergie"
222#   * add journal "Clim. Res."
223#   * add journal "Hydrol. Earth Sys. Sci."
224#   * add journal "Ambio"
225#   * add journal "Theoretical and applied climatology"
226#   * add journal "Remote Sensing of Environnement"
227#
228# - fplod 2008-10-28T11:40:19Z aedon.locean-ipsl.upmc.fr (Darwin)
229#
230#   * add journal "Progress In Oceanography"
231#   * add journal "Climatic Change"
232#   * add journal "Ocean Dynamics"
233#   * add journal "Phil. Trans. Roy. Soc. A"
234#   * add journal "Izvestiya Atmospheric and Oceanic Physics"
235#   * add journal "Journal of Hydrometeorology"
236#   * add journal "Remote Sensing of Environment"
237#   * add journal "Oceanology"
238#   * add journal "Water Resour. Res."
239#   * add journal "Advances in Atmospheric Sciences"
240#   * add journal "Quaternary Science Reviews"
241#   * replace "Elsevier Oceanography Series" by "Elsevier Oceanographic Series"
242#   * bug fix : unclosed date tag
243#   * trouble with flat conversion for id building ...
244#   * remove interactivity at then end (allowing redirection of stderr and
245#     stdout)
246#   * strip blank lines
247#   * bug fix : counting nb of occurences of "," technique ... to be improved
248#
249# - fplod 2008-09-16T15:19:59Z aedon.locean-ipsl.upmc.fr (Darwin)
250#
251#   * comments in ReStructured Text
252#
253# - fplod 2008-05-16T10:33:16Z aedon.locean-ipsl.upmc.fr (Darwin)
254#
255#   * add parameter -o for firstname/surname order in bibtex file
256#
257# - fplod 2008-05-15T15:15:04Z aedon.locean-ipsl.upmc.fr (Darwin)
258#
259#   * new way of processing bibtex file : external/bibtex2xml.py
260#
261# - fplod 2008-04-30T07:11:58Z aedon.locean-ipsl.upmc.fr (Darwin)
262#
263#   * chgt for dbk5 out
264#   * xmlto 0.0.18 does'nt like this docbook release. remove
265#   * usage of xml (xmlstarlet) for validation
266#   * bug fix
267#   * add journal names from demo1
268#   * fplod 2008-03-12T16:11:07Z aedon.locean-ipsl.upmc.fr (Darwin)
269#   * add -p option (to overide bibrefnemo in file name and id)
270#   * add -l option by default en
271#
272# - fplod 2008-03-11T11:25:27Z aedon.locean-ipsl.upmc.fr (Darwin)
273#
274#   * add bibtex entry (not finished)
275#
276# - fplod 2007-06-20T17:18:02Z aedon.locean-ipsl.upmc.fr (Darwin)
277#
278#   * <bibliomisc role="id"> replace by <biblioid class="doi">
279#
280# - smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin)
281#
282#   * Add journals
283#
284# - fplod 2007-05-10T09:17:09Z aedon.locean-ipsl.upmc.fr (Darwin)
285#
286#   * dernières touches
287#
288# - fplod 2007-04-25T10:59:49Z cerbere.locean-ipsl.upmc.fr (Linux)
289#
290#   * add a filein parameter and an option for mailbody
291#   * comments (line begininig with #) are now possible
292#
293# - Sebastien Masson avril 2007
294#
295#   * creation
296#
297#-
298
299rmbl () {
300   echo "${1}" | sed -e "s/^ *//" | sed -e "s/ *$//"
301}
302cleanname () {
303   echo "${1}" | sed -e "s/^ *//" \
304      -e "s/^ *,//" \
305      -e "s/^ *;//" \
306      -e "s/^ *\.//" \
307      -e "s/ *$//" \
308      -e "s/, *$//" \
309      -e "s/; *$//" \
310      -e "s/\. *$//"
311}
312#
313system=$(uname)
314case "${system}" in
315   AIX|IRIX64)
316      echo " www : no specific posix checking"
317   ;;
318   *)
319      set -o posix
320   ;;
321esac
322unset system
323#
324set -u
325#
326command=$(basename ${0})
327log_date=$(date -u +"%Y%m%dT%H%M%SZ")
328log=/tmp/$(basename ${command} .sh).log.${log_date}
329#
330# test if xsltproc is available
331tool=xsltproc
332type ${tool} 1> /dev/null 2>&1
333status=${?}
334if [ ${status} -ne 0 ]
335then
336   echo " eee : ${tool} not found"
337   exit 1
338fi
339unset status
340unset tool
341#
342# test if xml is available
343tool=xml
344type ${tool} 1> /dev/null 2>&1
345status=${?}
346if [ ${status} -ne 0 ]
347then
348   echo " eee : ${tool} not found"
349   exit 1
350fi
351unset status
352unset tool
353#
354# test if python is available
355tool=python
356type ${tool} 1> /dev/null 2>&1
357status=${?}
358if [ ${status} -ne 0 ]
359then
360   echo " eee : ${tool} not found"
361   exit 1
362fi
363unset status
364unset tool
365#
366# test if recode is available
367tool=recode
368type ${tool} 1> /dev/null 2>&1
369status=${?}
370if [ ${status} -ne 0 ]
371then
372   echo " eee : ${tool} not found"
373   exit 1
374fi
375unset status
376unset tool
377#
378usage=" Usage : ${command} -i filein -ti typein -o order -p project -l lang -to typeout"
379#
380# default
381lang=en
382# fs mean "firstname surname"
383order="fs"
384typeout="dbk"
385#
386minargcount=6
387#echo " narg ${#}"
388if [ ${#} -lt ${minargcount} ]
389then
390   echo "eee : not enought arguments"
391   echo "${usage}"
392   exit 1
393fi
394unset minargcount
395#
396while [ ${#} -gt 0 ]
397do
398   case ${1} in
399      -i)
400         filein=${2}
401         shift
402      ;;
403      -ti)
404         typein=${2}
405         shift
406      ;;
407      -to)
408         typeout=${2}
409         shift
410      ;;
411      -o)
412         # order of firstname surname in bibtex file
413         order=${2}
414         shift
415      ;;
416      -p)
417         project=${2}
418         shift
419      ;;
420      -l)
421         lang=${2}
422         shift
423      ;;
424      -h)
425         echo "${usage}"
426         exit 0
427      ;;
428      *)
429         # other choice
430         echo "eee : unknown option ${1}"
431         echo "${usage}"
432         exit 1
433      ;;
434   esac
435   # next flag
436   shift
437done
438unset usage
439#
440# check for filein
441if [ ! -f ${filein} ]
442then
443   echo "eee : ${filein} not found"
444   exit 1
445fi
446#
447case ${typeout} in
448   dbk)
449      fileou=$( basename ${filein} .txt).xml
450   ;;
451   bibtex)
452      fileou=$( basename ${filein} .txt).bib
453   ;;
454   *)
455      echo "eee : typeout should be dbk or bibtex"
456      exit 1
457   ;;
458esac
459#
460# check for output
461case ${typein} in
462   raw)
463      # file like data/biball.txt
464      fileraw=${filein}
465   ;;
466   mailbody)
467      # file like data/mail2007-04-25T08:58:16Z.txt
468      fileraw=/tmp/$(basename ${filein}).raw
469      echo "# from ${filein}" > ${fileraw}
470      echo "# ${log_date}" >> ${fileraw}
471      echo "# corrections" >> ${fileraw}
472      grep "correction_.*=" ${filein} | grep -v "correction_.*=$" | \
473         sed -e "s/correction_.*=//">> ${fileraw}
474      echo "# new references" >> ${fileraw}
475      awk "/newreferences=/,/comments=/" ${filein} | sed -e "s/newreferences=//" -e "/comments=/d" >> ${fileraw}
476      #more ${fileraw} # ++ if debug
477      #read a #++ if debug
478   ;;
479   bibtex)
480      # file like data/petitpoly.bib
481      fileraw=/tmp/$(basename ${filein}).raw
482      awk -f join_endcomma.awk ${filein} > ${fileraw}
483   ;;
484   *)
485      echo "eee : typein should be raw, mailbody or bibtex"
486      exit 1
487   ;;
488esac
489#
490# check for output
491if [ -f ${fileou} ]
492then
493   echo "eee : ${fileou} already exist"
494   exit 1
495fi
496#
497ij=1
498jlist[${ij}]="J. Climate"
499ij=$(( ${ij} + 1))
500jlist[${ij}]="Journal of Climate"
501ij=$(( ${ij} + 1))
502jlist[${ij}]="Ocean Modelling"
503ij=$(( ${ij} + 1))
504jlist[${ij}]="Geophys. Res. Lett."
505ij=$(( ${ij} + 1))
506jlist[${ij}]="J. Geophys. Res."
507ij=$(( ${ij} + 1))
508jlist[${ij}]="Tellus A"
509ij=$(( ${ij} + 1))
510jlist[${ij}]="Tellus B"
511ij=$(( ${ij} + 1))
512jlist[${ij}]="J. Phys. Oceanogr."
513ij=$(( ${ij} + 1))
514jlist[${ij}]="Clim. Dyn."
515ij=$(( ${ij} + 1))
516jlist[${ij}]="Clim. Res."
517ij=$(( ${ij} + 1))
518jlist[${ij}]="Climate Dynamics"
519ij=$(( ${ij} + 1))
520jlist[${ij}]="Dynamics of Atmospheres and Oceans"
521ij=$(( ${ij} + 1))
522jlist[${ij}]="Dyn. Atmos. Oceans"
523ij=$(( ${ij} + 1))
524jlist[${ij}]="Mon. Wea. Rev."
525ij=$(( ${ij} + 1))
526jlist[$ij]="Monthly Weather Review"
527ij=$(( ${ij} + 1))
528jlist[${ij}]="Global Biogeochem. Cycles"
529ij=$(( ${ij} + 1))
530jlist[${ij}]="Nonlinear Processes in Geophysics"
531ij=$(( ${ij} + 1))
532jlist[${ij}]="Ocean Sci."
533ij=$(( ${ij} + 1))
534jlist[${ij}]="Ocean Science"
535ij=$(( ${ij} + 1))
536jlist[${ij}]="Ocean Sciences"
537ij=$(( ${ij} + 1))
538jlist[${ij}]="J. Mar. Systems"
539ij=$(( ${ij} + 1))
540jlist[${ij}]="J. Atmos. Sc."
541ij=$(( ${ij} + 1))
542jlist[${ij}]="Proc. Royal Soc."
543ij=$(( ${ij} + 1))
544jlist[${ij}]="Bull. Amer. Meteorol. Soc."
545ij=$(( ${ij} + 1))
546jlist[${ij}]="Ocean Dyn."
547ij=$(( ${ij} + 1))
548jlist[${ij}]="Geophysical Monograph Series, Earth's Climate: The Ocean-Atmosphere Interaction"
549ij=$(( ${ij} + 1))
550jlist[${ij}]="Paleoceanography"
551ij=$(( ${ij} + 1))
552jlist[${ij}]="Annales Geophysicae"
553ij=$(( ${ij} + 1))
554jlist[${ij}]="Annals of Geophys."
555ij=$(( ${ij} + 1))
556jlist[${ij}]="Deep Sea Research Part II: Topical Studies in Oceanography"
557ij=$(( ${ij} + 1))
558jlist[${ij}]="Deep Sea Res. II"
559ij=$(( ${ij} + 1))
560jlist[${ij}]="Atmospheric Chemistry and Physics"
561ij=$(( ${ij} + 1))
562jlist[${ij}]="Atmospheric Chemistry and Physics Discussions"
563ij=$(( ${ij} + 1))
564jlist[${ij}]="Earth Plan. Sc. Lett."
565ij=$(( ${ij} + 1))
566jlist[${ij}]="J. Mar. Res."
567ij=$(( ${ij} + 1))
568jlist[${ij}]="PCMDI Report Series"
569ij=$(( ${ij} + 1))
570jlist[${ij}]="J. Mar. Syst."
571ij=$(( ${ij} + 1))
572jlist[${ij}]="Note du Pole de Modelisation"
573ij=$(( ${ij} + 1))
574jlist[${ij}]="Calculateurs Paralleles"
575ij=$(( ${ij} + 1))
576jlist[${ij}]="Note Scientifique du Pole de Modelisation"
577ij=$(( ${ij} + 1))
578jlist[${ij}]="Lecture Notes in Computer Science"
579ij=$(( ${ij} + 1))
580jlist[${ij}]="Prog. Oceanogr."
581ij=$(( ${ij} + 1))
582jlist[${ij}]="Deep Sea Research Part I: Oceanographic Research Papers"
583ij=$(( ${ij} + 1))
584jlist[${ij}]="Deep Sea Res. I"
585ij=$(( ${ij} + 1))
586jlist[${ij}]="IEEE Trans. Geosci. Remote Sensing"
587ij=$(( ${ij} + 1))
588jlist[${ij}]="ECMWF Tech. Memorandum"
589ij=$(( ${ij} + 1))
590jlist[${ij}]="J. Environ. Radioactivity"
591ij=$(( ${ij} + 1))
592jlist[${ij}]="Int. WOCE Newsletter"
593ij=$(( ${ij} + 1))
594jlist[${ij}]="C. R. Acad. Sci. Paris"
595ij=$(( ${ij} + 1))
596jlist[${ij}]="C. R. Acad. Sci. Paris, Earth and Planetary Sciences"
597ij=$(( ${ij} + 1))
598jlist[${ij}]="In The mathematics of models for climatology and environment"
599ij=$(( ${ij} + 1))
600jlist[${ij}]="Oceanol. Acta"
601ij=$(( ${ij} + 1))
602jlist[${ij}]="The global atmosphere and ocean system"
603ij=$(( ${ij} + 1))
604jlist[${ij}]="NATO Advanced Study Institute"
605ij=$(( ${ij} + 1))
606jlist[${ij}]="WCRP"
607ij=$(( ${ij} + 1))
608jlist[${ij}]="The Courier"
609ij=$(( ${ij} + 1))
610jlist[${ij}]="Elsevier Oceanography Series"
611ij=$(( ${ij} + 1))
612jlist[${ij}]="In Conference Proceedings of the 1988 International Conference on Supercomputing"
613ij=$(( ${ij} + 1))
614jlist[${ij}]="In Science and engineering on Cray Supercomputers"
615ij=$(( ${ij} + 1))
616jlist[${ij}]="In Modeling the Earth's Climate and its Variability"
617ij=$(( ${ij} + 1))
618jlist[${ij}]="Fish. Oceanogr."
619ij=$(( ${ij} + 1))
620jlist[${ij}]="Q. J. R. Meteor. Soc."
621ij=$(( ${ij} + 1))
622jlist[${ij}]="In High performance computing in the geosciences"
623ij=$(( ${ij} + 1))
624jlist[${ij}]="Int. J. Numer. Meth. in Fluids"
625ij=$(( ${ij} + 1))
626jlist[${ij}]="Lecture notes in Physics"
627ij=$(( ${ij} + 1))
628jlist[${ij}]="J. Meterol. Soc. Japan"
629ij=$(( ${ij} + 1))
630jlist[${ij}]="Journal of Marine Systems"
631ij=$(( ${ij} + 1))
632jlist[${ij}]="Canadian Journal of Fisheries and Aquatic Sciences"
633ij=$(( ${ij} + 1))
634jlist[${ij}]="J. Atmos. Ocean. Tech."
635ij=$(( ${ij} + 1))
636jlist[${ij}]="EOS"
637ij=$(( ${ij} + 1))
638jlist[${ij}]="Nature"
639ij=$(( ${ij} + 1))
640jlist[${ij}]="Nature Geosciences"
641ij=$(( ${ij} + 1))
642jlist[${ij}]="Physics and Chemistry of the Earth, Part B: Hydrology, Oceans and Atmosphere"
643ij=$(( ${ij} + 1))
644jlist[${ij}]="Journal of Atmospheric and Oceanic Technology"
645ij=$(( ${ij} + 1))
646jlist[${ij}]="Lecture Notes in Computational Science Engineering"
647ij=$(( ${ij} + 1))
648jlist[${ij}]="In Greenhouse Gas Control Technologies"
649ij=$(( ${ij} + 1))
650jlist[${ij}]="Chemical Geology"
651ij=$(( ${ij} + 1))
652jlist[${ij}]="Marine Geology"
653ij=$(( ${ij} + 1))
654jlist[${ij}]="Developments in Paleoenvironmental Research"
655ij=$(( ${ij} + 1))
656jlist[${ij}]=" Developments in Earth and Environmental Sciences"
657ij=$(( ${ij} + 1))
658jlist[${ij}]="Science"
659ij=$(( ${ij} + 1))
660jlist[${ij}]="In Mediterranean Climate Variability"
661ij=$(( ${ij} + 1))
662jlist[${ij}]="Global and Planetary Change"
663ij=$(( ${ij} + 1))
664jlist[${ij}]="Physical Review Letters"
665ij=$(( ${ij} + 1))
666jlist[${ij}]="Progress In Oceanography"
667ij=$(( ${ij} + 1))
668jlist[${ij}]="Climatic Change"
669ij=$(( ${ij} + 1))
670jlist[${ij}]="Ocean Dynamics"
671ij=$(( ${ij} + 1))
672jlist[${ij}]="Phil. Trans. Roy. Soc. A"
673ij=$(( ${ij} + 1))
674jlist[${ij}]="Phil. Trans. Roy. Soc. B"
675ij=$(( ${ij} + 1))
676jlist[${ij}]="Izvestiya Atmospheric and Oceanic Physics"
677ij=$(( ${ij} + 1))
678jlist[${ij}]="Journal of Hydrometeorology"
679ij=$(( ${ij} + 1))
680jlist[${ij}]="Journal of Hydrology"
681ij=$(( ${ij} + 1))
682jlist[${ij}]="Remote Sensing of Environment"
683ij=$(( ${ij} + 1))
684jlist[${ij}]="Remote Sensing Env."
685ij=$(( ${ij} + 1))
686jlist[${ij}]="Oceanology"
687ij=$(( ${ij} + 1))
688jlist[${ij}]="Water Resour. Res."
689ij=$(( ${ij} + 1))
690jlist[${ij}]="Water Resources Research"
691ij=$(( ${ij} + 1))
692jlist[${ij}]="Advances in Atmospheric Sciences"
693ij=$(( ${ij} + 1))
694jlist[${ij}]="Quaternary Science Reviews"
695ij=$(( ${ij} + 1))
696jlist[${ij}]="AGU monograph Ocean Circulation Mechanisms and Impacts"
697ij=$(( ${ij} + 1))
698jlist[${ij}]="Climate Research"
699ij=$(( ${ij} + 1))
700jlist[$ij]="Colloque du GIS « Climat-Environnement-Sociétés »"
701ij=$(( ${ij} + 1))
702jlist[$ij]="Agricultural and Forest Meteorology"
703ij=$(( ${ij} + 1))
704jlist[$ij]="VIIth IAHS Scientific Assembly"
705ij=$(( ${ij} + 1))
706jlist[$ij]="AGU fall Meeting"
707ij=$(( ${ij} + 1))
708jlist[$ij]="4th Alexander Von Humboldt International Conference"
709ij=$(( ${ij} + 1))
710jlist[$ij]="International Journal of Climatology"
711ij=$(( ${ij} + 1))
712jlist[$ij]="Revue de l'Énergie"
713ij=$(( ${ij} + 1))
714jlist[$ij]="Hydrol. Earth Sys. Sci."
715ij=$(( ${ij} + 1))
716jlist[$ij]="Ambio"
717ij=$(( ${ij} + 1))
718jlist[$ij]="Theoretical and applied climatology"
719ij=$(( ${ij} + 1))
720jlist[$ij]="Remote Sensing of Environnement"
721ij=$(( ${ij} + 1))
722jlist[$ij]="PNAS"
723ij=$(( ${ij} + 1))
724jlist[$ij]="Lettre PIGB-PMRC"
725ij=$(( ${ij} + 1))
726jlist[$ij]="High Performance Computing in Science and Engineering"
727ij=$(( ${ij} + 1))
728jlist[$ij]="High Performance Computing in Science and Engineering '08"
729ij=$(( ${ij} + 1))
730jlist[$ij]="High Performance Computing on Vector Systems 2006"
731ij=$(( ${ij} + 1))
732jlist[$ij]="High Performance Computing on Vector Systems 2007"
733ij=$(( ${ij} + 1))
734jlist[$ij]="Annals of Glaciology"
735ij=$(( ${ij} + 1))
736jlist[$ij]="Oceanography"
737ij=$(( ${ij} + 1))
738jlist[$ij]="Journal of Physical Oceanography"
739ij=$(( ${ij} + 1))
740jlist[$ij]="In Deep convection and deep water formation in the oceans"
741ij=$(( ${ij} + 1))
742jlist[$ij]="Journal of Applied Meteorology and Climatology"
743ij=$(( ${ij} + 1))
744jlist[$ij]="Geochem. Geophys. Geosyst."
745ij=$(( ${ij} + 1))
746jlist[$ij]="Environmental Fluid Mechanics"
747ij=$(( ${ij} + 1))
748jlist[$ij]="Continental Shelf Research"
749ij=$(( ${ij} + 1))
750jlist[$ij]="Marine Pollution Bulletin"
751ij=$(( ${ij} + 1))
752jlist[$ij]="Comptes Rendus Geosciences"
753ij=$(( ${ij} + 1))
754jlist[$ij]="??"
755#
756# following Journal name are fake ones for demo1 : references extracted from
757# Cantratrix Sopronica L. written by Georges Perec
758#find in http://www-rocq.inria.fr/who/Marc.Thiriet/PsFil/Biblio/cantatrix.ps
759ij=$(( ${ij} + 1))
760jlist[$ij]="Res. Proc. neurophysiol. Fanatic Soc."
761ij=$(( ${ij} + 1))
762jlist[$ij]="New Records Ass. J."
763ij=$(( ${ij} + 1))
764jlist[$ij]="Am. J. Allegrol."
765ij=$(( ${ij} + 1))
766jlist[$ij]="J. Neurochem. Neurocytol. Enzymol."
767ij=$(( ${ij} + 1))
768jlist[$ij]="Hammersmith J."
769ij=$(( ${ij} + 1))
770jlist[$ij]="Nasa Rept."
771ij=$(( ${ij} + 1))
772jlist[$ij]="C.r. Assoc. Conc. Lam."
773ij=$(( ${ij} + 1))
774jlist[$ij]="Gaz. med. franco-rus."
775ij=$(( ${ij} + 1))
776jlist[$ij]="Amer. J. music. Deciency"
777#
778# strip comments and blank lines
779fileraw_strict=/tmp/$(basename ${fileraw})_strict
780grep -v "^#" ${fileraw} | grep -v "^%" | sed "/^$/d" > ${fileraw_strict}
781# following line is not compatible with XML header ++
782# comments for memory (why did I write this line !?)
783# iconv -f ISO-8859-1 -t UTF-8 ${fileraw_strict} > ${fileraw_strict}2
784# mv ${fileraw_strict}2 ${fileraw_strict}
785case ${typein} in
786   bibtex)
787      fileou_bibtexml=/tmp/$(basename ${fileraw})_bibtexml
788      python ./external/bibtex2xml.py ${fileraw_strict} > ${fileou_bibtexml}
789basename: missing operand
790Try `basename --help' for more information.
791      #more  ${fileou_bibtexml}
792      #read a
793      xsltproc --output ${fileou} \
794         --param lang "'${lang}'" \
795         --param project "'${project}'" \
796         --param makedate "'${log_date}'" \
797         --param order "'${order}'" \
798         bibtexml2dbk.xsl ${fileou_bibtexml}
799      rm ${fileou_bibtexml}
800   ;;
801   *)
802      case ${typeout} in
803         dbk)
804            cat <<EOF > ${fileou}
805<?xml version='1.0' encoding='ISO-8859-1'?>
806<bibliography
807version="5.0"
808xmlns="http://docbook.org/ns/docbook"
809xml:id="bib${project}ref"
810xml:lang="${lang}">
811
812<info>
813<date>${log_date}</date>
814</info>
815EOF
816         ;;
817         bibtex)
818            cat <<EOF > ${fileou}
819
820@PREAMBLE{"bibliography of ${project}"}"
821
822% ${log_date}
823
824EOF
825         ;;
826      esac
827      totlines=$( wc -l ${fileraw_strict} | awk '{print $1}' )
828      l=1
829      while [ ${l} -le ${totlines} ]
830      do
831#echo "line: $l"
832         # extract one line
833         line=$( sed -n ${l}p ${fileraw_strict} )
834         orgline=$( echo ${line} | sed -e "s/--/- -/g" )
835         line=$( echo ${line} | sed -e "s/</\&lt;/g" -e "s/>/\&gt;/g" )
836         # parsing non bibtex line
837         bibtex=0
838         # before the first :
839         tmp=${line%%:*}
840         # before the last ,
841         auths=${tmp%,*},
842         # replace " and " by ","
843         auths=$( echo "${auths}" | sed -e "s/ and /,/g" )
844         # replace " et " by ","
845         auths=$( echo "${auths}" | sed -e "s/ et /,/g" )
846         # after the last ,
847         year=${tmp##*,}
848         year=$( rmbl "${year}" )
849         ## first author before the first .,
850         first=${auths%%.,*}.
851         # its firstname after the last ,
852         firstfn=${first##*,}
853         firstfn=$( rmbl "${firstfn}" )
854         # its surname ; before the first ,
855         firstsn=${first%%,*}
856         firstsn=$( rmbl "${firstsn}" )
857         ## ref id
858         firstsn_flat=$( echo "${firstsn}" | recode -d -f ISO-8859-15..flat )
859         # echo "firstsn : ${firstsn}" # ++ debug
860         # echo "firstsn_flat : ${firstsn_flat}" #++ debug
861         # test if no encoding problem after ISO-8859-15 to flat conversion
862         firstsn_test1=$(echo "${firstsn_flat}" | tr -d "[:alpha:]" | tr -d " " | tr -d "'" | tr -d "-" | tr -d ".")
863         # echo "firstsn_test1 : ${firstsn_test1}" # ++ debug
864         if [ ! -z "${firstsn_test1}" ]
865         then
866            echo "www : pb on ISO-8859-15 to flat conversion"
867            echo "www : on ${firstsn}"
868            echo "www : trying UTF-8 to flat conversion ..."
869            firstsn_flat=$( echo "${firstsn}" | recode -d -f UTF-8..flat )
870            # test if no encoding problem after UTF-8 to flat conversion
871            firstsn_test2=$(echo "${firstsn_flat}" | tr -d "[:alpha:]" | tr -d " " | tr -d "'")
872            #echo "firstsn_test2 : A${firstsn_test2}A" # ++ debug
873            if [ ! -z "${firstsn_test2}" ]
874            then
875               echo "eee : pb on flat conversion of ${firstsn}"
876               exit 1
877            fi
878         fi
879         firstsn_lower=$( echo "${firstsn_flat}" | tr "[:upper:]" "[:lower:]")
880         firstsn_nopunct=$( echo "${firstsn_lower}" | tr -s " " "_"  | tr -s "'" "_")
881         refid="${firstsn_nopunct}${year}"
882         unset firstsn_lower
883         unset firstsn_flat
884         unset firstsn_test1
885         unset firstsn_test2
886         # look for id of biblio entry to produce a unique one
887         case ${typeout} in
888            dbk)
889               num=$( grep -c "<biblioentry xml:id=\"${refid}_[0-9][0-9]\">" ${fileou} )
890            ;;
891            bibtex)
892               num=$( grep -c "@.*{${refid}_[0-9][0-9]," ${fileou} )
893            ;;
894         esac
895         num=$(( ${num} + 1 ))
896         [ ${num} -le 9 ] && num=0${num}
897         refid=${refid}_${num}
898         hasauthor=1
899         case ${typeout} in
900            dbk)
901               cat <<EOF >> ${fileou}
902<biblioentry xml:id="${refid}">
903  <!-- date $( date -u +"%Y%m%dT%H%M%SZ" ) -->
904  <!-- original text
905  ${orgline}
906  -->
907EOF
908            ;;
909            bibtex)
910               cat <<EOF >> ${fileou}
911%
912% date $( date -u +"%Y%m%dT%H%M%SZ" )
913% original text :
914% ${orgline}
915%
916@article{${refid},
917EOF
918            ;;
919         esac
920         if [ ${hasauthor} -eq 1 ]
921         then
922            case ${typeout} in
923               dbk)
924                  cat <<EOF >> ${fileou}
925  <authorgroup>
926    <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author>
927EOF
928               ;;
929               bibtex)
930                  cat <<EOF >> ${fileou}
931author = {${firstsn}, ${firstfn}},
932EOF
933               ;;
934           esac
935
936            ## other authors..
937            if [ ${bibtex} -eq 0 ]
938            then
939               previous=${first},
940               # next authors...
941               next=${auths##*${previous}}
942            fi
943            if [ ${bibtex} -eq 1 ]
944            then
945               previous=${first}"and "
946               # next authors...
947               #echo "auths ${auths}"
948               next=${auths##*${previous}}
949               if [ "${next}and " = "${previous}" ]
950               then
951                  next=""
952               fi
953            fi
954            #echo "previous ${previous}"
955            #echo "next ${next}"
956            # while the next author is not empty
957            while [  "${next}" != "" ]
958            do
959               if [ ${bibtex} -eq 0 ]
960               then
961                  # get the first next author; before the first ,
962                  next=${next%%,*}
963                  # its surname ; after the last .
964                  nextsn=${next##*.}
965                  nextsn=$( rmbl "${nextsn}" )
966                  # its firstname ; before the last .
967                  nextfn=${next%.*}.
968                  nextfn=$( rmbl "${nextfn}" )
969               fi
970               if [ ${bibtex} -eq 1 ]
971               then
972                  # get the first next author; before the first "and"
973                  next=${next%%and *}
974                  # its surname after the last " "  ++ pas vrai double nom et pb blanc dans la syntaxe
975                  # nextsn=${next##* } . ok en interactif . pas ok en script
976                  nextsn=$( echo ${next}  | awk '{print $2}')
977                  #echo "nextsn $nextsn"
978                  # its nextname before the first " "
979                  nextfn=${next%% *}
980               fi
981    #
982               case ${typeout} in
983                  dbk)
984                     echo "    <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou}
985                  ;;
986                  bibtex)
987                     echo "author = {${nextsn}, ${nextfn}}," >> ${fileou}
988                  ;;
989               esac
990               if [ ${bibtex} -eq 0 ]
991               then
992                  previous=${next},
993                  next=${auths##*${previous}}
994               fi
995               if [ ${bibtex} -eq 1 ]
996               then
997                  previous=${next}"and "
998                  next=${auths##*${previous}}
999               fi
1000            done
1001            case ${typeout} in
1002               dbk)
1003                  echo "  </authorgroup>"  >> ${fileou}
1004               ;;
1005            esac
1006         fi
1007         # end of the line ; after the first :
1008         endline=${line#*:}
1009         ## find the journal
1010         j=1
1011         jfound=""
1012         jlistsize=${#jlist[@]}
1013         while [[ ${j} -le ${jlistsize} && "${jfound}" == "" ]]
1014         do
1015            ok=$( echo ${endline} | grep -ci "${jlist[j]} *," )
1016            [ ${ok} -eq 1 ] && jfound="${jlist[j]}"
1017            j=$(( ${j} + 1 ))
1018         done
1019         unset ok
1020         if [ "${jfound}" == "" ]
1021         then
1022            echo "eee: Journal not found "
1023            echo "${endline}"
1024            # uncomment next line for debug
1025            # set # ++ debug
1026            exit 1
1027            #+++ following lines are not yet validate
1028            # it might be a book, a manual, a conference, etc. ++
1029            case ${typeout} in
1030               dbk)
1031                  echo "  <title>${title}</title>" >> ${fileou}
1032                  cat <<EOF >> ${fileou}
1033  <biblioset relation="nojournal">
1034    <title>${title}</title>
1035    <pagenums>${pag}</pagenums>
1036    <pubdate>${year}</pubdate>
1037  </biblioset>
1038</biblioentry>
1039EOF
1040               ;;
1041               bibtex)
1042                  echo "title = {${title}}," >> ${fileou}
1043                  echo "pages = {${pag}}," >> ${fileou}
1044                  echo "year = {${year}}" >> ${fileou}
1045                  echo "}" >> ${fileou}
1046               ;;
1047            esac
1048            # end of if jfound empty (ie not an article)
1049         fi
1050         if [ "${jfound}" != "" ]
1051         then
1052            ## title
1053            # before the first :
1054            title=${endline%%${jfound}*}
1055            title=$( cleanname "${title}" )
1056            case ${typeout} in
1057               dbk)
1058                  echo "  <title>${title}</title>" >> ${fileou}
1059               ;;
1060               bibtex)
1061                  echo "title = {${title}}," >> ${fileou}
1062            esac
1063            ## end
1064            ## end of the line ; after the first ${jfound}
1065            endline=${endline#*${jfound}}
1066            endline=$( cleanname "${endline}" )
1067            ## doi
1068            endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" )
1069            #echo "endline for doi ${endline}"
1070            ok=$( echo ${endline} | grep -ic "doi:" )
1071            if [ ${ok} -eq 1 ]
1072            then
1073               doi=${endline##*doi:}
1074               #echo "doi : $doi"
1075               case ${typeout} in
1076                  dbk)
1077                     echo "  <biblioid class=\"doi\">${doi}</biblioid>" >> ${fileou}
1078                  ;;
1079                  bibtex)
1080                     echo "doi={${doi}}," >> ${fileou}
1081                  ;;
1082               esac
1083               unset doi
1084               endline=${endline%doi:*}
1085               endline=$( cleanname "${endline}" )
1086            else
1087               echo "non doi: ${line}"
1088               echo ""
1089            fi
1090            num=$( echo "${endline}" |  tr -dc "," | wc -c | tr -d " ")
1091            case "${num}" in
1092               0)
1093                  ## echo ${num}: ${endline}
1094                  case ${typeout} in
1095                     dbk)
1096                        cat <<EOF >> ${fileou}
1097  <biblioset relation="journal">
1098    <title>${jfound}</title>
1099    <pubdate>${year}</pubdate>
1100    <bibliomisc>${endline}</bibliomisc>
1101  </biblioset>
1102EOF
1103                      ;;
1104                      bibtex)
1105                        cat <<EOF >> ${fileou}
1106journal = {${jfound}},
1107year = {${year}},
1108notes = {${endline}},
1109EOF
1110                      ;;
1111                 esac
1112                  unset jfound
1113                  unset year
1114               ;;
1115               1)
1116                  ### echo ${num}: ${endline}
1117                  vol=${endline%,*}
1118                  vol=$( cleanname "${vol}" )
1119                  pag=${endline##*,}
1120                  pag=$( cleanname "${pag}" )
1121                  case ${typeout} in
1122                     dbk)
1123                        cat <<EOF >> ${fileou}
1124  <biblioset relation="journal">
1125    <title>${jfound}</title>
1126    <volumenum>${vol}</volumenum><pagenums>${pag}</pagenums>
1127    <pubdate>${year}</pubdate>
1128  </biblioset>
1129EOF
1130                     ;;
1131                     bibtex)
1132                        echo "journal = {${jfound}}," >> ${fileou}
1133                        echo "volume = {${vol}}," >> ${fileou}
1134                        echo "pages = {${pag}}," >> ${fileou}
1135                        echo "year = {${year}}," >> ${fileou}
1136                     ;;
1137                  esac
1138               ;;
1139               bibtex)
1140                  unset vol
1141                  unset pag
1142                  unset jfound
1143                  unset year
1144               ;;
1145               2)
1146                  vol=${endline%,*}
1147                  vol=$( cleanname "${vol}" )
1148                  iss=${vol##*,}
1149                  iss=$( cleanname "${iss}" )
1150                  vol=${vol%,*}
1151                  vol=$( cleanname "${vol}" )
1152                  pag=${endline##*,}
1153                  pag=$( cleanname "${pag}" )
1154                  case ${typeout} in
1155                     dbk)
1156                        cat <<EOF >> ${fileou}
1157  <biblioset relation="journal">
1158    <title>${jfound}</title>
1159    <volumenum>${vol}</volumenum><issuenum>${iss}</issuenum><pagenums>${pag}</pagenums>
1160    <pubdate>${year}</pubdate>
1161  </biblioset>
1162EOF
1163                     ;;
1164                     bibtex)
1165                        echo "journal = {${jfound}}," >> ${fileou}
1166                        echo "volume = {${vol}}," >> ${fileou}
1167                        echo "number = {${iss}}," >> ${fileou}
1168                        echo "pages = {${pag}}," >> ${fileou}
1169                        echo "year = {${year}}," >> ${fileou}
1170                     ;;
1171                  esac
1172                  unset vol
1173                  unset pag
1174                  unset jfound
1175                  unset year
1176                  unset iss
1177               ;;
1178               6)
1179                  conftitle=${endline%%,*}
1180                  endline=${endline#*,}
1181                  # day(s) month
1182                  confdates=${endline%%,*}
1183                  endline=${endline#*,}
1184                  # day(s) month and year
1185                  confdates="${confdates}, ${endline%%,*}"
1186                  confdates=$( cleanname "${confdates}" )
1187                  endline=${endline#*,}
1188                  # Town
1189                  confaddress=${endline%%,*}
1190                  endline=${endline#*,}
1191                  # Town and country
1192                  confaddress="${confaddress}, ${endline%%,*}"
1193                  confaddress=$( cleanname "${confaddress}" )
1194                  endline=${endline#*,}
1195                  publishername=${endline%%,*}
1196                  publishername=$( cleanname "${publishername}" )
1197                  endline=${endline#*,}
1198                  pag=${endline##*,}
1199                  pag=$( cleanname "${pag}" )
1200                  #set
1201                  #read a
1202                  case ${typeout} in
1203                     dbk)
1204                        cat <<EOF >> ${fileou}
1205<biblioset relation="conference">
1206 <title>${jfound}</title>
1207 <pubdate>${year}</pubdate>
1208 <publisher><publishername>${publishername}</publishername></publisher>
1209 <pagenums>${pag}</pagenums>
1210 <confgroup>
1211  <conftitle>${conftitle}</conftitle>
1212  <confdates>${confdates}</confdates>
1213  <address>${confaddress}</address>
1214 </confgroup>
1215</biblioset>
1216EOF
1217                     ;;
1218                     bibtex)
1219                        echo "journal = {${jfound}}," >> ${fileou}
1220                        echo "year = {${year}}," >> ${fileou}
1221                        echo "publisher = {${publishername}}," >> ${fileou}
1222                        echo "booktitle = {${conftitle}}," >> ${fileou}
1223                        echo "date = {${confdates}}," >> ${fileou}
1224                        echo "address = {${confaddress}}," >> ${fileou}
1225                     ;;
1226                  esac
1227                  unset confaddress
1228                  unset conftitle
1229                  unset confdates
1230                  unset pag
1231                  unset publishername
1232                  unset year
1233                  unset jfound
1234               ;;
1235               10)
1236                  publishername=${endline%%Editors,*}
1237                  publishername="${publishername} Editors"
1238                  publishername=$( cleanname "${publishername}" )
1239                  endline=${endline#*Editors,}
1240                  vol=${endline%%,*}
1241                  vol=$( cleanname "${vol}" )
1242                  endline=${endline#*,}
1243                  pag=${endline%%,*}
1244                  pag=$( cleanname "${pag}" )
1245                  endline=${endline#*,}
1246                  isbn=${endline%%,*}
1247                  isbn=$(echo ${isbn} | sed -e "s/ISBN ://")
1248                  isbn=$( cleanname "${isbn}" )
1249                  endline=${endline#*,}
1250                  agu=${endline%%,*}
1251                  agu=$(echo ${agu} | sed -e "s/AGU ://")
1252                  agu=$( cleanname "${agu}" )
1253                  endline=${endline#*${agu}}
1254                  endline=$( cleanname "${endline}" )
1255                  endline=$( cleanname "${endline}" )
1256                  case ${typeout} in
1257                     dbk)
1258                        cat <<EOF >> ${fileou}
1259  <biblioid class="isbn">${isbn}</biblioid>
1260  <biblioid class="other" otherclass="AGU">${agu}</biblioid>
1261  <biblioset relation="journal">
1262    <title>${jfound}</title>
1263    <pubdate>${year}</pubdate>
1264    <publisher><publishername>${publishername}</publishername></publisher>
1265    <volumenum>${vol}</volumenum>
1266    <pagenums>${pag}</pagenums>
1267    <bibliomisc>${endline}</bibliomisc>
1268  </biblioset>
1269EOF
1270                     ;;
1271                     bibtex)
1272                        echo "isbn= {${isbn}}," >> ${fileou}
1273                        echo "agu= {${agu}}," >> ${fileou}
1274                        echo "year = {${year}}," >> ${fileou}
1275                        echo "journal = {${jfound}}," >> ${fileou}
1276                        echo "publisher = {${publishername}}," >> ${fileou}
1277                        echo "volume = {${vol}}," >> ${fileou}
1278                        echo "pages = {${pag}}," >> ${fileou}
1279                        echo "notes = {${endline}}," >> ${fileou}
1280                     ;;
1281                  esac
1282                  unset isbn
1283                  unset agu
1284                  unset pag
1285                  unset publishername
1286                  unset year
1287                  unset jfound
1288                  unset vol
1289               ;;
1290               *)
1291                  #echo "${num}: ${endline}" # ++debug
1292                  #set # ++ debug
1293                  #exit 1 #++ debug
1294                  case ${typeout} in
1295                     dbk)
1296                        cat <<EOF >> ${fileou}
1297  <biblioset relation="journal">
1298    <title>${jfound}</title>
1299    <pubdate>${year}</pubdate>
1300    <bibliomisc>${endline}</bibliomisc>
1301  </biblioset>
1302EOF
1303                     ;;
1304                     bibtex)
1305                        echo "journal = {${jfound}}," >> ${fileou}
1306                        echo "year = {${year}}," >> ${fileou}
1307                        echo "notes = {${endline}}," >> ${fileou}
1308                     ;;
1309                  esac
1310               ;;
1311            esac
1312            case ${typeout} in
1313               dbk)
1314                  echo "</biblioentry>" >> ${fileou}
1315               ;;
1316               bibtex)
1317                  echo "}" >> ${fileou}
1318               ;;
1319            esac
1320            # end of if jfound not empty
1321         fi
1322         unset title
1323         unset vol
1324         unset year
1325         unset pag
1326         l=$(( ${l} + 1 ))
1327      done
1328      unset totlines
1329      unset l
1330      case ${typeout} in
1331         dbk)
1332            echo "</bibliography>" >> ${fileou}
1333         ;;
1334      esac
1335   ;;
1336# end of case bibtex vs other for processing
1337esac
1338
1339# check conformity of fileou
1340# if possible
1341case ${typeout} in
1342   dbk)
1343      xml val --err \
1344         --xsd http://www.docbook.org/xml/5.0/xsd/docbook.xsd \
1345         ${fileou} 1> xmlstarlet.log 2>&1
1346      #
1347      # clean
1348      echo " iii : xmlstarlet.log contains sdtout and stderr from xml command on ${fileou}"
1349      echo " iii : which was done just to check consistence of ${fileou}"
1350      more xmlstarlet.log
1351      #
1352   ;;
1353   bibtex)
1354      echo " iii : no check conformity of bibtex file"
1355   ;;
1356esac
1357#
1358case ${typein} in
1359   raw)
1360      echo " iii : ${fileraw_strict} contains a copy of input file without comments"
1361   ;;
1362   mailbody)
1363      echo " iii : ${fileraw} contains a copy of input file"
1364      echo " iii : ${fileraw_strict} contains a copy of input file without comments"
1365   ;;
1366esac
1367#
1368echo " iii : you have a some new or modified bibliographic references in ${fileou} (biblioentry)"
1369echo " iii : you can add them in ${fileou}" #++ filename path
1370echo " iii : modify date in ${fileou}" #++ filename path
1371echo " iii : but please take care of id last part (after underscore) that may"
1372echo " iii : be in conflict with existing ones" #++ pour s'affranchir de ce souci il faudrait donner en entrée complémentaire le fichier à compléter.
1373#
1374exit 0
Note: See TracBrowser for help on using the repository browser.