4

Here's a MWE that I thought it would only remove entries without the annotation AKA annote field. But actually it removes all of the entries.

Here's what the documentation says, on page 78 of the biblatex manual:

If notfield is used then only apply the step if the ⟨entryfield⟩ does not exist.

If entrynull is set, processing of the \map immediately terminates and the current entry is not created. It is as if it did not exist in the datasource. Obviously, you should select the entries which you want to apply this to using prior mapping steps.

By wrapping these into one step I thought I would first test if the annotation field is set, and then, if not, delete the entry. Is there a way to achieve that.

\documentclass{article}

\usepackage[style=reading,
            entryhead=true,
            entrykey=false,
            natbib,
            hyperref=false,
            url=false,
            doi=false,
            %style=apa,
            sorting=nyt,
            isbn=false,
            %backref=true,
            firstinits=true,
            minnames=13,
            maxnames=35,
            minbibnames=10,
            maxbibnames=100,
            parentracker=true,
            defernumbers=true,
            backend=biber]{biblatex}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
     \step[notfield=annotation,entrynull=true]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@inproceedings{ABCDFG,
  annote = {This is a very nice paper.},
  author = {GGPB},
  booktitle = {BOEUS},
  keywords = {clipping},
  title = {NOAP},
  volume = {0},
  year = {2005},
}
@inproceedings{XXXXXX,
  author = {PQR},
  booktitle = {BBC},
  keywords = {LLM},
  title = {ARP},
  year = {2010},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\nocite{*}

\printbibliography

\end{document}
1
  • 2
    This looks like a bug specific to entrynull to me. \step[notfield=annote, fieldset=note, fieldvalue=Note] works as expected. Note: You should use annote as is actually in your bib file, not annotation as this mapping isn't yet applied at the time your user mapping. Commented Oct 12, 2018 at 1:49

1 Answer 1

5

Data mapping happens at a very early state when the annote field is still called annote and not yet annotation (the renaming from annote to annotation also happens in a sourcemap, but that map is executed after user-defined \DeclareSourcemaps). So you need notfield=annote.

Furthermore, it seems that entrynull only works safely if it is used in a \step of its own. All examples in the documentation use it like this.

If you think that \step[notfield=annotation,entrynull=true] should work (and from the text of the documentation I found no compelling argument that it should not), please open an issue at the Biber bugtracker: https://github.com/plk/biber/issues.

edit: There was a discussion about this on the Biber bugracker at https://github.com/plk/biber/issues/238. As a consequence the biblatex documentation has been amended to emphasise that notfield should be used in a \step of its own together with final.

To catch entries without annote and annotation and null them I suggest

\documentclass{article}
\usepackage[style=reading, backend=biber]{biblatex}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
     \step[notfield=annote, final]
     \step[notfield=annotation, final]
     \step[entrynull]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@inproceedings{ABCDFG,
  annote    = {This is a very nice paper.},
  author    = {GGPB},
  booktitle = {BOEUS},
  keywords  = {clipping},
  title     = {NOAP},
  volume    = {0},
  year      = {2005},
}
@inproceedings{XXXXXX,
  author    = {PQR},
  booktitle = {BBC},
  keywords  = {LLM},
  title     = {ARP},
  year      = {2010},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

Only <code>ABCDFG</code> (with <code>annote</code>) appears in the bibliography, <code>XXXXXX</code> (without <code>annote</code>) is not present

3
  • The logic is the reverse of what I'm after: entries with empty annotations are preserved as such, and anything that is not empty is nullified. The behaviour is the same as in my original MWE. Commented Oct 12, 2018 at 11:52
  • @JoeCorneli Sorry, I might have misunderstood you. I thought you wanted to see the entry with annote (ABCDFG in the MWE) and wanted to null everything else (XXXXXX). That is what my MWE does - see the added full MWE and picture.
    – moewe
    Commented Oct 12, 2018 at 12:06
  • OK, it works! I think I forgot to run biber. Sorry for the noise, and thanks for the updated answer! Apart from that oversight the wording of the manual is a bit confusing: "If notfield is used then only apply the step if the ⟨*entryfield*⟩ does not exist." I would have thought that the first step in the recipe would match any items without an annote, then result in final which means no further steps executed. Commented Oct 12, 2018 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .