BibTeX output to XML
11. März 2010 – 16:51Publishing online BibTeX references is not just matter of converting a .bib
file to XML/HTML. If there is a print (PDF) edition, two very important items
should be the same in both print and online versions:
- same entries
- same sorting
Further editing of the online references includes for example
- abreviation of the author/editor names
- inclundig and formatting the needed fields
The publisher’s demands for the online references are often included in the
DTD describing the XML tags for the online documents. In the worst case the
online formatting differs from the print formatting. Nevertheless, if there is
already a LaTeX/BibTeX workflow, and especially a BibTeX style file, it is
better to use directliy BibTeX (the program) to produce the XML output instead
of external converters. Using BibTeX guaranties automatically that the both
items above are true. Further, if one is familiar with the BibTeX programming
syntax and with the used style file, it is easy to modify the functions to
produce the XML output, while keeping the framework unchanged.
Below is an example of a BibTeX function which formats the author names
acoording to the Springer A++ DTD. It is part of an BibTeX style file, which I
wrote years ago for the print and online references in the Springer series
Topics in Applied Physics. The first names are abbreviated and put in
<Initials> tag, the whole name is in <BibAthorName> and so on.
FUNCTION {format.authornames.online}
{ 'bibinfo :=
duplicate$ empty$ 'skip$ {
's :=
"" 't :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ " <BibAuthorName> "
s nameptr "{f.}" format.name$
duplicate$ empty$
{ " <NoInitials/>" * * }
{ "<Initials>" swap$ * * "</Initials>" * }
if$
s nameptr
" <FamilyName>{ll}</FamilyName> " format.name$ *
s nameptr "{vv{}}" format.name$
duplicate$ empty$
{ * }
{ "<Particle>" swap$ * * "</Particle>" * }
if$
s nameptr "{jj{}}" format.name$
duplicate$ empty$
{ * }
{ "<Suffix>" swap$ * * "</Suffix>" * }
if$
"</BibAuthorName> " *
bibinfo bibinfo.check
't :=
nameptr #1 >
{
namesleft #1 >
{ " " * t * }
{
"" *
s nameptr "{ll}" format.name$ duplicate$ "others" =
{ 't := }
{ pop$ }
if$
t "others" =
{
" " * bbl.etal.online *
}
{ " " * t * }
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
} if$
}
So, processing for example the bib entry
-
author = {J. U. Lee and
-
P. J. Codella and
-
M. Pietrzykowski},
-
journal = {Appl. Phys. Lett.},
-
volume = {90},
-
pages = {053103},
-
year = {2007},
-
}
yields to the XML code
-
<!– BibTeX Label: lee07 –>
-
<!– BibTeX Type: article –>
-
<BibArticle>
-
<BibAuthorName>
-
<Initials>J. U.</Initials>
-
<FamilyName>Lee</FamilyName>
-
</BibAuthorName>
-
<BibAuthorName>
-
<Initials>P. J.</Initials>
-
<FamilyName>Codella</FamilyName>
-
</BibAuthorName>
-
<BibAuthorName>
-
<Initials>M.</Initials>
-
<FamilyName>Pietrzykowski</FamilyName>
-
</BibAuthorName>
-
<Year>2007</Year>
-
<NoArticleTitle/>
-
<JournalTitle>Appl. Phys. Lett.</JournalTitle>
-
<VolumeID>90</VolumeID>
-
<FirstPage>053103</FirstPage>
-
</BibArticle>
-
<BibUnstructured>
-
J. U. Lee, P. J. Codella, M. Pietrzykowski: Appl. Phys. Lett. <Emphasis Type="Bold">90</Emphasis>, 053103 (2007)
-
</BibUnstructured>
-
</Citation>
The XML code can be then validated and integrataded in the whole online file.
Tags: A++, BibTeX, DTD, online, references, Springer, TAP, Topics Applied Physics, XML