Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461<Chapter Label="ch:bibutil">2<Heading>Utilities for Bibliographies</Heading>34A standard for collecting references (in particular to mathematical5texts) is &BibTeX;6(<URL>http://www.ctan.org/tex-archive/biblio/bibtex/distribs/doc/</URL>).7A disadvantage of &BibTeX; is that the format of the8data is specified with the use by &LaTeX; in mind. The data format is9less suited for conversion to other document types like plain text or10HTML.<P/>1112In the first section we describe utilities for using data from &BibTeX;13files in &GAP;. <P/>1415In the second section we introduce a new XML based data format16BibXMLext for bibliographies which seems better suited for other17tasks than using it with &LaTeX;. <P/>1819Another section will describe utilities to deal with BibXMLext20data in &GAP;.212223<Section Label="ParseBib">24<Heading>Parsing &BibTeX; Files</Heading>2526Here are functions for parsing, normalizing and printing reference lists27in &BibTeX; format. The reference describing this format is <Cite28Key="La85" Where="Appendix B"/>.2930<#Include Label="ParseBibFiles">3132<#Include Label="NormalizeNameAndKey">3334<#Include Label="WriteBibFile">3536<#Include Label="LabelsFromBibTeX">3738<#Include Label="InfoBibTools">3940</Section>4142<Section Label="BibXMLformat">43<Heading>The BibXMLext Format</Heading>4445Bibliographical data in &BibTeX; files have the disadvantage that the46actual data are given in &LaTeX; syntax. This makes it difficult to use47the data for anything but for &LaTeX;, say for representations of the48data as plain text or HTML. For example: mathematical formulae are in49&LaTeX; <C>$</C> environments, non-ASCII characters can be50specified in many strange ways, and how to specify URLs for links if the51output format allows them?<P/>5253Here we propose an XML data format for bibliographical data which54addresses these problems, it is called BibXMLext. In the next55section we describe some tools for56generating (an approximation to) this data format from &BibTeX; data,57and for using data given in BibXMLext format for various58purposes. <P/>5960The first motivation for this development was the handling of61bibliographical data in &GAPDoc;, but the format and the tools are certainly62useful for other purposes as well.<P/>6364We started from a DTD <F>bibxml.dtd</F> which is publicly available, say65from <URL>http://bibtexml.sf.net/</URL>. This is essentially a66reformulation of the definition of the &BibTeX; format, including67several of some widely used further fields. This has already the68advantage that a generic XML parser can check the validity of the69data entries, for example for missing compulsary fields in entries.70We applied the following changes and extensions to define the71DTD for BibXMLext, stored in the file <F>bibxmlext.dtd</F> which can72be found in the root directory of this &GAPDoc; package (and in Appendix73<Ref Appendix="bibxmlextdtd"/>):7475<List >76<Mark>names</Mark>77<Item>Lists of names in the <C>author</C> and <C>editor</C> fields in78&BibTeX; are difficult to parse. Here they must be given by a sequence79of <C><name></C>-elements which each contain an optional <C><first></C>-80and a <C><last></C>-element for the first and last names,81respectively.</Item>82<Mark><C><M></C> and <C><Math></C></Mark>83<Item>These elements enclose mathematical formulae, the content is84&LaTeX; code (without the <C>$</C>). These should be handled in85the same way as the elements with the same names in &GAPDoc;, see86<Ref Subsect="M"/> and <Ref Subsect="Math"/>. In particular, simple87formulae which have a well defined plain text representation can be88given in <C><M></C>-elements.</Item>89<Mark>Encoding</Mark>90<Item>Note that in XML files we can use the full range of unicode91characters, see <URL>http://www.unicode.org/</URL>. All non-ASCII92characters should be specified as unicode characters. This makes dealing93with special characters easy for plain text or HTML, only for use with94&LaTeX; some sort of translation is necessary.</Item>95<Mark><C><URL></C></Mark>96<Item>These elements are allowed everywhere in the text and should be97represented by links in converted formats which allow this. It is used98in the same way as the element with the same name in &GAPDoc;, see99<Ref Subsect="URL"/>.</Item>100<Mark><C><Alt Only="..."></C> and <C><Alt Not="..."></C></Mark>101<Item>Sometimes information should be given in different ways, depending102on the output format of the data. This is possible with the103<C><Alt></C>-elements with the same definition as in &GAPDoc;, see104<Ref Subsect="Alt"/>.105</Item>106<Mark><C><C></C></Mark>107<Item>This element should be used to protect text from case changes by108converters (the extra <C>{}</C> characters in &BibTeX;109title fields).</Item>110<Mark><C><string key="..." value="..."/></C> and111<C><value key="..."/></C></Mark>112<Item>The <C><string></C>-element defines key-value pairs which can113be used in any field via the <C><value></C>-element (not only for114whole fields but also parts of the text).</Item>115<Mark><C><other type="..."></C></Mark>116<Item>This is a generic element for fields which are otherwise not117supported. An arbitrary number of them is allowed for each entry, so any118kind of additional data can be added to entries.</Item>119<Mark><C><Wrap Name="..."></C></Mark>120<Item>This generic element is allowed inside all fields. This markup will be121just ignored (but not the element content) by our standard tools. But122it can be a useful hook for introducing arbitrary further markup123(and our tools can easily be extended to handle it).</Item>124<Mark>Extra entities</Mark>125<Item>The DTD defines the standard XML entities (<Ref126Subsect="XMLspchar"/> and the entities <C>&nbsp;</C> (non-breakable127space), <C>&ndash;</C> and <C>&copyright;</C>.128Use <C>&ndash;</C> in page ranges.129</Item>130</List>131132For further details of the DTD we refer to the file <F>bibxmlext.dtd</F>133itself which is shown in appendix <Ref Appendix="bibxmlextdtd"/>. That134file also recalls some information from the &BibTeX; documentation on how135the standard fields of entries should be used. Which entry types and136which fields are supported (and the ordering of the fields which is137fixed by a DTD) can be either read off the DTD, or within &GAP; one can use138the function <Ref Func="TemplateBibXML"/> to get templates for the139various entry types.140<P/>141142Here is an example of a BibXMLext document:143<Listing Type="doc/testbib.xml"><![CDATA[144<#Include SYSTEM "testbib.xml">145]]></Listing>146147There is a standard XML header and a <C>DOCTYPE</C> declaration148referring to the <F>bibxmlext.dtd</F> DTD mentioned above. Local149entities could be defined in the <C>DOCTYPE</C> tag as shown in the150example in <Ref Subsect="GDent"/>. The actual content of the document is151inside a <C><file></C>-element, it consists of <C><string></C>- and152<C><entry></C>-elements. Several of the BibXMLext markup features are153shown. We will use this input document for some examples below.154</Section>155156<Section Label="BibXMLtools">157<Heading>Utilities for BibXMLext data</Heading>158159<Subsection Label="Subsect:IntroXMLBib">160<Heading>Translating &BibTeX; to BibXMLext</Heading>161First we describe a tool which can translate bibliography entries from162&BibTeX; data to BibXMLext <C><entry></C>-elements. It also does some163validation of the data. In some164cases it is desirable to improve the result by hand afterwards165(editing formulae, adding <C><URL></C>-elements, translating166non-ASCII characters to unicode, ...).<P/>167See <Ref Func="WriteBibXMLextFile"/> below for how to write the results168to a BibXMLext file.169</Subsection>170171<#Include Label="StringBibAsXMLext">172173The following functions allow parsing of data which are already in174BibXMLext format.175176<#Include Label="ParseBibXMLextString">177178<#Include Label="WriteBibXMLextFile">179180<Subsection Label="Subsect:RecBib">181<Heading>Bibliography Entries as Records</Heading>182For working with BibXMLext entries we find it convenient to first183translate the parse tree of an entry, as returned by <Ref184Func="ParseBibXMLextFiles"/>, to a record with the field names of the185entry as components whose value is the content of the field as string.186These strings are generated with respect to a result type. The records are187generated by the following function which can be customized by the user.188</Subsection>189190<#Include Label="RecBibXMLEntry">191192<#Include Label="AddHandlerBuildRecBibXMLEntry">193194<#Include Label="StringBibXMLEntry">195196The following command may be useful to generate completly new197bibliography entries in BibXMLext format. It also informs about the198supported entry types and field names.199200<#Include Label="TemplateBibXML">201202</Section>203204<#Include Label="SearchMRSection">205206</Chapter>207208209210211