# Datamodel distribution with biblatex

I am now making new tools to use biblatex in my studies area, i. e. classical philology.

Some of theses tools need new datatypes or new fields. For example, I am making two tools:

• one to manage manuscript description with biblatex: need new datatype (@manuscript) and new fields (support, dating, scribe, shelfmark etc.) (see https://github.com/maieul/biblatex-manuscripts-philology)
• one to add a new field, which is the true author of a text. I am explaining: the author field will contain the name of the author as edited, but the "realauthor" field will contain the name of the author whom scholars think is the real author of the work (problem of pseudonym and false attribution, very often in my specialty)

These two tools are independent. I hope these two tools are enough generic to be distributed as contribution. But here is my problem. If I read well the biblatex handbook, in the section "4.5.3 Data Model Specification", I don't see how I could distribute my two contribution independently AND allow people to use them in the same project.

• I can't distribute them as styles: only one style can be precised when loading biblatex.
• I can't distribute them as datamodel: only one datamodel can be precised when loading biblatex.
• biblatex-dm.cfg and biblatex.cfg have to be created by the user
• there is no possibility to define a datamodel in a .sty file.
• Since a datamodel declaring new field, entry types etc. is essentially useless without a style that is capable of using these fields, I do not really see a problem here. If people want to use what you've created, they will have to use a style that supports it (the style could load the data model) or will have to implement support for this themselves, in which case they can make their code load your data model. – moewe Jan 16 '14 at 21:14
• People who want a ready-made solution will need more than the data model files to benefit from those, so you could concatenate both files for end-user distribution. People who want to use this as a foundation for their style will be able to copy the relevant part of the data model file into their data model file (provided, of course, the license allows them to). – moewe Jan 16 '14 at 21:16
• of course, a datamodel must be used with a style file. I will distribute style files, but it could be quite little: just 2 renewbibmacros are enough. The other thing will be classical style (verbose family, for example) – Maïeul Jan 16 '14 at 21:20
• so the problem will be the same: my tools are not complete style, because the basic style are enough. It's juste provide some "little" hook. And the distribution problem is the same. – Maïeul Jan 16 '14 at 21:22
• Styles can load other styles internally: So your style files can load an appropriate style by default and modify that for users that don't like messing about with biblatex themselves. You can also provide the \renewbibmacros separately for package authors or those who like to play around with biblatex. – moewe Jan 16 '14 at 21:45

This is a bit hackish, but may be an inspiration for a proper solution.

Biblatex loads datamodels very early, before processing any options defined in biblatex style files (.bbx or .cbx). This is why you can't control datamodel loading from within a style. You need to do adjustments before the biblatex is called. Below I describe how this can be done with a package. I assume that your tools are additions to some base biblatex style which your users can freely choose. Suppose your style and package are called dmtools and you want two options manu (to load a manuscript datamodel defined in dmtools-manu.dbx) and fields (to load additional fields defined in dmtools-fields.dbx). You also have dmtools.bbx and dmtools.cbx with some macro definitions.

This is how these style and package are used:

\documentclass{article}
\usepackage[
basestyle=apa,
manu,
fields,
]{dmtools}

\usepackage[style=dmtools, ...]{biblatex}

\begin{document}
...
\end{document}


basestyle is the base biblatex style to which your tools will serve as additions. If you don't need it, that is if your tools are supposed to provide additions to one bib style only, you can move the biblatex call inside the .sty file.

Your package files then look like this:

dmtools.sty

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dmtools}

\RequirePackage{kvoptions}

% options declarations
%
\DeclareBoolOption{manu}
\DeclareBoolOption{fields}
\DeclareStringOption[numeric]{basestyle}

\ProcessKeyvalOptions*

\ifdmtools@manu
\def\dmtmanu{dmtools-manu}    % the name of .dbx file for the 'manu' tool
\fi

\ifdmtools@fields
\def\dmtfields{dmtools-fields}    % the name of .dbx file for the 'fields' tool
\fi

\ifx\dmtools@basestyle\@empty
\else
\def\dmtbasestyle{\dmtools@basestyle} % the name of bibstyle to load later
\fi

\endinput


This declares options and sets some commands and \if's to be used later. The basestyle option is optional and if absent the numeric style is used.

dmtools.dbx

% DM Tools data models

% load datamodel for the 'manu' tool
\ifdmtools@manu
\blx@inputonce{\dmtmanu.dbx}{DM Tools data model}{}{}{}{}
\fi

% load datamodel for the 'fields' tool
\ifdmtools@fields
\blx@inputonce{\dmtfields.dbx}{DM Tools data model}{}{}{}{}
\fi

% load datamodel for the style specified in the 'basestyle' option
\ifx\dmtools@basestyle\@empty
\else
\blx@inputonce{\dmtbasestyle.dbx}{biblatex style data model}{}{}{}{}
\fi

\endinput


This file loads your datamodels and also the datamodel for the basestyle. You will probably need to adjust this to handle also bibstyle and citestyle options.

Finally, bibliography and citation style files:

dmtools.bbx

\ProvidesFile{dmtools.bbx}

\RequireBibliographyStyle{\dmtbasestyle}

\ifdmtools@manu
%
%  macro (re)definitions
%
\fi

\ifdmtools@fields
%
%  macro (re)definitions
%
\fi

\endinput


dmtools.cbx

\ProvidesFile{dmtools.cbx}

\RequireCitationStyle{\dmtbasestyle}

\ifdmtools@manu
%
%  mscro (re)definitions
%
\fi

\ifdmtools@fields
%
%  mscro (re)definitions
%
\fi

\endinput


These files load the basestyle bib- and cite-styles and then (re)define macros/commands that you need for your tools.

• Thanks for your answer. This seems to look like well. But one point I don't understand welle is it: finally, my .dbx will load also the biblatex package ? – Maïeul Jan 18 '14 at 18:24
• Well, perhaps I misunderstood a little and you need something less complicated :) See my corrected answer. – Oleg Domanov Jan 19 '14 at 13:12
• I saw, that could be a great thing! Just let me finish my code and I saw that. – Maïeul Jan 19 '14 at 13:35
• your system seems to work. I made my own adaptation (github.com/maieul/biblatex-multiple-dm). I will make test and publish it when it will be stable and documented. – Maïeul Mar 16 '14 at 10:35
• I have also ask to add this feature in the main biblatex github.com/plk/biblatex/issues/219 – Maïeul Mar 16 '14 at 10:35