source: trunk/bibopa.sh @ 164

Last change on this file since 164 was 146, checked in by pinsard, 12 years ago

xmlstarlet vs xml

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