source: trunk/bibopa.sh

Last change on this file was 354, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo

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