summaryrefslogtreecommitdiff
path: root/support/crossrefware/ltx2crossrefxml.1
blob: 9f6800d8b7a0c2c286d9dfd25576d0abb5ae7f5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "ltx2crossrefxml 1"
.TH ltx2crossrefxml 1 2024-02-03 "" "LATEX CROSSREFWARE"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
ltx2crossrefxml.pl \- create XML files for submitting to crossref.org
.SH SYNOPSIS
.IX Header "SYNOPSIS"
ltx2crossrefxml [\fB\-c\fR \fIconfig_file\fR]  [\fB\-o\fR \fIoutput_file\fR] [\fB\-input\-is\-xml\fR]
                \fIlatex_file1\fR \fIlatex_file2\fR ...
.SH OPTIONS
.IX Header "OPTIONS"
.IP "\fB\-c\fR \fIconfig_file\fR" 4
.IX Item "-c config_file"
Configuration file.  If this file is absent, defaults are used.
See below for its format.
.IP "\fB\-o\fR \fIoutput_file\fR" 4
.IX Item "-o output_file"
Output file.  If this option is not used, the XML is output to stdout.
.IP \fB\-rpi\-is\-xml\fR 4
.IX Item "-rpi-is-xml"
Do not transform author and title input strings, assume they are valid XML.
.PP
The usual \f(CW\*(C`\-\-help\*(C'\fR and \f(CW\*(C`\-\-version\*(C'\fR options are also supported. Options
can begin with either \f(CW\*(C`\-\*(C'\fR or \f(CW\*(C`\-\-\*(C'\fR, and ordered arbitrarily.
.SH DESCRIPTION
.IX Header "DESCRIPTION"
For each given \fIlatex_file\fR, this script reads \f(CW\*(C`.rpi\*(C'\fR and (if they
exist) \f(CW\*(C`.bbl\*(C'\fR files and outputs corresponding XML that can be uploaded
to Crossref (<https://crossref.org>). Any extension of \fIlatex_file\fR is
ignored, and \fIlatex_file\fR itself is not read (and need not even exist).
.PP
Each \f(CW\*(C`.rpi\*(C'\fR file specifies the metadata for a single article to be
uploaded to Crossref (a \f(CW\*(C`journal_article\*(C'\fR element in their schema); an
example is below. These files are output by the \f(CW\*(C`resphilosophica\*(C'\fR
package (<https://ctan.org/pkg/resphilosophica>), but (as always) can
also be created by hand or by whatever other method you implement.
.PP
Any \f(CW\*(C`.bbl\*(C'\fR files present are used for the citation information in the
output XML. See the CITATIONS section below.
.PP
Unless \f(CW\*(C`\-\-rpi\-is\-xml\*(C'\fR is specified, for all text (authors, title,
citations), standard TeX control sequences are replaced with plain text
or UTF\-8 or eliminated, as appropriate. The \f(CW\*(C`LaTeX::ToUnicode::convert\*(C'\fR
routine is used for this (<https://ctan.org/pkg/bibtexperllibs>).
Tricky TeX control sequences will almost surely not be handled
correctly. If \f(CW\*(C`\-\-rpi\-is\-xml\*(C'\fR is given, the author and title strings
from the rpi files are output as-is, assuming they are valid XML; no
checking is done. Citation text from \f(CW\*(C`.bbl\*(C'\fR files is always converted
from LaTeX to plain text.
.PP
This script just writes an XML file. It's up to you to actually do the
uploading to Crossref; for example, you can use their Java tool 
\&\f(CW\*(C`crossref\-upload\-tool.jar\*(C'\fR
(<https://www.crossref.org/education/member\-setup/direct\-deposit\-xml/https\-post>).
For the definition of their schema, see
<https://data.crossref.org/reports/help/schema_doc/4.4.2/index.html>
(this is the schema version currently followed by this script).
.SH "CONFIGURATION FILE FORMAT"
.IX Header "CONFIGURATION FILE FORMAT"
The configuration file is read as Perl code. Thus, comment lines
starting with \f(CW\*(C`#\*(C'\fR and blank lines are ignored. The other lines are
typically assignments in the form (spaces are optional):
.PP
.Vb 1
\&    $variable = value ;
.Ve
.PP
Usually the value is a \f(CW"string"\fR enclosed in ASCII double-quote or
single-quote characters, per Perl syntax. The idea is to specify the
user-specific and journal-specific values needed for the Crossref
upload. The variables which are used are these:
.PP
.Vb 7
\&    $depositorName = "Depositor Name";
\&    $depositorEmail = \*(Aqdepositor@example.org\*(Aq;
\&    $registrant = \*(AqRegistrant\*(Aq;  # organization name
\&    $fullTitle = "FULL TITLE";   # journal name
\&    $issn = "1234\-5678";         # required
\&    $abbrevTitle = "ABBR. TTL."; # optional
\&    $coden = "CODEN";            # optional
.Ve
.PP
For a given run, all \f(CW\*(C`.rpi\*(C'\fR data read is assumed to belong to the
journal that is specified in the configuration file. More precisely, the
configuration data is written as a \f(CW\*(C`journal_metadata\*(C'\fR element, with
given \f(CW\*(C`full_title\*(C'\fR, \f(CW\*(C`issn\*(C'\fR, etc., and then each \f(CW\*(C`.rpi\*(C'\fR is written as
\&\f(CW\*(C`journal_issue\*(C'\fR plus \f(CW\*(C`journal_article\*(C'\fR elements.
.PP
The configuration file can also define one Perl function:
\&\f(CW\*(C`LaTeX_ToUnicode_convert_hook\*(C'\fR. If it is defined, it is called at the
beginning of the procedure that converts LaTeX text to Unicode, which is
done with the LaTeX::ToUnicode module, from the \f(CW\*(C`bibtexperllibs\*(C'\fR
package (<https://ctan.org/pkg/bibtexperllibs>). The function must
accept one string (the LaTeX text), and return one string (presumably
the transformed string). The standard conversions are then applied to
the returned string, so the configured function need only handle special
cases, such as control sequences particular to the journal at hand.
.SH "RPI FILE FORMAT"
.IX Header "RPI FILE FORMAT"
Here's the (relevant part of the) \f(CW\*(C`.rpi\*(C'\fR file corresponding to the
\&\f(CW\*(C`rpsample.tex\*(C'\fR example in the \f(CW\*(C`resphilosophica\*(C'\fR package
(<https://ctan.org/pkg/resphilosophica>):
.PP
.Vb 10
\&  %authors=Boris Veytsman\eand A. U. Th{\eo }r\eand C. O. R\e"espondent
\&  %title=A Sample Paper:\e\e \eemph  {A Template}
\&  %year=2012
\&  %volume=90
\&  %issue=1\-\-2
\&  %startpage=1
\&  %endpage=1
\&  %doi=10.11612/resphil.A31245
\&  %paperUrl=http://borisv.lk.net/paper12
\&  %publicationType=full_text
.Ve
.PP
Other lines, some not beginning with %, are ignored (and not shown).
For more details on processing, see the code.
.PP
The \f(CW%paperUrl\fR value is what will be associated with the given \f(CW%doi\fR
(output as the \f(CW\*(C`resource\*(C'\fR element). Crossref strongly recommends that
the url be for a so-called landing page, and not directly for a pdf
(<https://www.crossref.org/education/member\-setup/creating\-a\-landing\-page/>).
Special case: if the url is not specified, 
and the journal is \fIRes\ Philosophica\fR,
a special-purpose search url using pdcnet.org is returned.
Any other journal must always specify this.
.PP
The \f(CW%authors\fR field is split at \f(CW\*(C`\eand\*(C'\fR (ignoring whitespace before
and after), and output as the \f(CW\*(C`contributors\*(C'\fR element, using
\&\f(CW\*(C`sequence="first"\*(C'\fR for the first listed, \f(CW\*(C`sequence="additional"\*(C'\fR for
the remainder.
.PP
If the \f(CW%publicationType\fR is not specified, it defaults to
\&\f(CW\*(C`full_text\*(C'\fR, since that has historically been the case; \f(CW\*(C`full_text\*(C'\fR
can also be given explicitly. The other values allowed by the Crossref
schema are \f(CW\*(C`abstract_only\*(C'\fR and \f(CW\*(C`bibliographic_record\*(C'\fR. Finally, if the
value is \f(CW\*(C`omit\*(C'\fR, the \f(CW\*(C`publication_type\*(C'\fR attribute is omitted entirely
from the given \f(CW\*(C`journal_article\*(C'\fR element.
.PP
Each \f(CW\*(C`.rpi\*(C'\fR must contain information for only one article, but multiple
files can be read in a single run. It would not be difficult to support
multiple articles in a single \f(CW\*(C`.rpi\*(C'\fR file, but it makes debugging and
error correction easier when each uploaded XML contains a single
article.
.SS "MORE ABOUT AUTHOR NAMES"
.IX Subsection "MORE ABOUT AUTHOR NAMES"
The three formats for names recognized are (not coincidentally) the same
as BibTeX:
.PP
.Vb 3
\&   First von Last
\&   von Last, First
\&   von Last, Jr., First
.Ve
.PP
The forms can be freely intermixed within a single \f(CW%authors\fR line,
separated with \f(CW\*(C`\eand\*(C'\fR (including the backslash). Commas as name
separators are not supported, unlike BibTeX.
.PP
In short, you may almost always use the first form; you shouldn't if
either there's a Jr part, or the Last part has multiple tokens but
there's no von part. See the \f(CW\*(C`btxdoc\*(C'\fR (``BibTeXing'' by Oren Patashnik)
document for details.
.PP
In the \f(CW%authors\fR line of a \f(CW\*(C`.rpi\*(C'\fR file, some secondary directives are
recognized, indicated by \f(CW\*(C`|\*(C'\fR characters. Easiest to explain with an
example:
.PP
.Vb 1
\&  %authors=|organization|\eLaTeX\e Project Team \eand Alex Brown|orcid=123
.Ve
.PP
Thus: 1) if \f(CW\*(C`|organization|\*(C'\fR is specified, the author name will be output
as an \f(CW\*(C`organization\*(C'\fR contributor, instead of the usual \f(CW\*(C`person_name\*(C'\fR,
as the Crossref schema requires.
.PP
2) If \f(CW\*(C`|orcid=\fR\f(CIvalue\fR\f(CW|\*(C'\fR is specified, the \fIvalue\fR is output as an
\&\f(CW\*(C`ORCID\*(C'\fR element for that \f(CW\*(C`person_name\*(C'\fR.
.PP
These two directives, \f(CW\*(C`|organization\*(C'\fR| and \f(CW\*(C`|orcid|\*(C'\fR are mutually
exclusive, because that's how the Crossref schema defines them. The \f(CW\*(C`=\*(C'\fR
sign after \f(CW\*(C`orcid\*(C'\fR is required, while all spaces after the \f(CW\*(C`orcid\*(C'\fR
keyword are ignored. Other than that, the ORCID value is output
literally. (E.g., the ORCID value of \f(CW123\fR above is clearly invalid,
but it would be output anyway, with no warning.)
.PP
Extra \f(CW\*(C`|\*(C'\fR characters, at the beginning or end of the entire \f(CW%authors\fR
string, or doubled in the middle, are accepted and ignored. Whitespace
is ignored around all \f(CW\*(C`|\*(C'\fR characters.
.SH CITATIONS
.IX Header "CITATIONS"
Each \f(CW\*(C`.bbl\*(C'\fR file corresponding to an input \f(CW\*(C`.rpi\*(C'\fR file is read and
used to output a \f(CW\*(C`citation_list\*(C'\fR element for that \f(CW\*(C`journal_article\*(C'\fR in
the output XML. If no \f(CW\*(C`.bbl\*(C'\fR file exists for a given \f(CW\*(C`.rpi\*(C'\fR,
no \f(CW\*(C`citation_list\*(C'\fR is output for that article.
.PP
The \f(CW\*(C`.bbl\*(C'\fR processing is rudimentary: only so-called
\&\f(CW\*(C`unstructured_citation\*(C'\fR references are produced for Crossref, that is,
the contents of the citation (each paragraph in the \f(CW\*(C`.bbl\*(C'\fR) is dumped
as a single flat string without markup.
.PP
Bibliography text is unconditionally converted from TeX to XML, via the
method described above. It is not unusual for the conversion to be
incomplete or incorrect.  It is up to you to check for this; e.g., if
any backslashes remain in the output, it is most likely an error.
.PP
Furthermore, it is assumed that the \f(CW\*(C`.bbl\*(C'\fR file contains a sequence of
references, each starting with \f(CW\*(C`\ebibitem{\fR\f(CIKEY\fR\f(CW}\*(C'\fR (which itself must be
at the beginning of a line, preceded only by whitespace), and the whole
bibliography ending with \f(CW\*(C`\eend{thebibliography}\*(C'\fR (similarly at the
beginning of a line). A bibliography not following this format will not
produce useful results. Bibliographies can be created by hand, or with
BibTeX, or any other method.
.PP
The \f(CW\*(C`key\*(C'\fR attribute for the \f(CW\*(C`citation\*(C'\fR element is taken as the \fIKEY\fR
argument to the \f(CW\*(C`\ebibitem\*(C'\fR command. The sequential number of the
citation (1, 2, ...) is appended. The argument to \f(CW\*(C`\ebibitem\*(C'\fR can be
empty (\f(CW\*(C`\ebibitem{}\*(C'\fR, and the sequence number will be used on its own.
Although TeX will not handle empty \f(CW\*(C`\ebibitem\*(C'\fR keys, it can be
convenient when creating a \f(CW\*(C`.bbl\*(C'\fR purely for Crossref.
.PP
The \f(CW\*(C`.rpi\*(C'\fR file is also checked for the bibliography information, in
this same format.
.PP
Feature request: if anyone is interested in figuring out how to generate
structured citations
(<https://data.crossref.org/reports/help/schema_doc/5.3.1/schema_5_3_1.html#citation>)
instead of these flat text dumps, that would be great. Except the schema
seems to support much less than described at
<https://www.crossref.org/documentation/principles\-practices/best\-practices/bibliographic/>?
Anyway, the most viable approach is probably to change tugboat.bst to
output no-op TeX commands like \etubibauthor, \etubibtitle, etc. (a la
biblatex), and use those commands to discern the various crossref field
values. We can't start from the .bib because then we'd have to
reimplement Bib(La)TeX.
.SH EXAMPLES
.IX Header "EXAMPLES"
.Vb 2
\&  ltx2crossrefxml.pl ../paper1/paper1.tex ../paper2/paper2.tex \e
\&                      \-o result.xml
\&
\&  ltx2crossrefxml.pl \-c myconfig.cfg paper.tex \-o paper.xml
.Ve
.SH AUTHOR
.IX Header "AUTHOR"
Boris Veytsman <https://github.com/borisveytsman/crossrefware>
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
Copyright (C) 2012\-2024  Boris Veytsman
.PP
This is free software.  You may redistribute copies of it under the
terms of the GNU General Public License (any version)
<https://www.gnu.org/licenses/gpl.html>.  There is NO WARRANTY, to the
extent permitted by law.