2

I try to set up things so that if the url field is used, urldate has to be used as well. Below is what I have so far. There seems to be a mistake since biber -V complains about all three entries to be lacking a urldate field. The ideal solution would not complain about the acl85 entry, since it is complete. It would also not complain about CP85a-irgendwo, since it inherits both fields from acl85, but it should complain about the CP85a-nirgendwo item, since it overwrites the url but has an inherited urldate field. I do not know whether it is possible to catch the last case. But getting the other two to work, would be great already.

\documentclass{article}

\begin{filecontents}{\jobname.bib}

@inproceedings{CP85a-irgendwo,
        Author = {Lewis G. Creary and Carl J. Pollard},
        Crossref = {acl85},
        Pages = {172--179},
        Title = {A Computational Semantics for Natural Language}}

@inproceedings{CP85a-nirgendwo,
        Author = {Lewis G. Creary and Carl J. Pollard},
        Crossref = {acl85},
        url = {http://nirgendwo.de},
        Pages = {172--179},
        Title = {A Computational Semantics for Natural Language}}

@proceedings{acl85,
        Address = {Chicago, IL},
        Editor = {Mann, William C.},
        Publisher = {acl},
        Title = {Proceedings of the {Twenty-Third Annual Meeting of the Association for
Computational Linguistics}},
        url = {http://irgendwo.de},
        urldate = {2021-02-15},
        Year = {1985}}


\end{filecontents}
\begin{filecontents}{bookparent.dbx}
\DeclareDatamodelEntryfields[book]{
  booktitle}

\DeclareDatamodelFields[type=field,datatype=date]{
   urldate}
\DeclareDatamodelEntryfields{urldate}

\ResetDatamodelConstraints

\DeclareDatamodelConstraints[
  article,
  book,
  inbook,
  bookinbook,
  suppbook,
  booklet,
  collection,
  incollection,
  suppcollection,
  manual,
  misc,
  mvbook,
  mvcollection,
  online,
  patent,
  periodical,
  suppperiodical,
  proceedings,
  inproceedings,
  reference,
  inreference,
  report,
  set,
  thesis,
  unpublished]{
    \constraint[type=mandatory]{
      \constraintfieldsxor{
        \constraintfield{date}
        \constraintfield{year}
      }
    }
    % if there is an URL then there should be a urldate field.
    \constraint[type=conditional]{
      \antecedent[quantifier=one]{
        \constraintfield{url}
      }
      \consequent[quantifier=all]{
          \constraintfield{urldate}
      }
    }
  }


\end{filecontents}


\usepackage[
  natbib=true,
  backend=biber,
  datamodel=bookparent,
]{biblatex}
\addbibresource{\jobname.bib}

\begin{document}
\autocite{CP85a-nirgendwo,CP85a-irgendwo}

\printbibliography
\end{document}

1 Answer 1

3

date fields are a bit special in biblatex, since they are parsed during the Biber run and split up for biblatex into its date parts.

Apparently data model constraint verification happens at a very late stage where date parsing and splitting has already occurred, so you don't want to test for presence of the urldate field, you want to check for urlyear, urlmonth and urlday.

\documentclass{article}

\begin{filecontents}{\jobname.bib}
@inproceedings{CP85a-irgendwo,
  author   = {Lewis G. Creary and Carl J. Pollard},
  crossref = {acl85},
  pages    = {172--179},
  title    = {A Computational Semantics for Natural Language},
}
@inproceedings{CP85a-nirgendwo,
  author   = {Lewis G. Creary and Carl J. Pollard},
  crossref = {acl85},
  url      = {http://nirgendwo.de},
  pages    = {172--179},
  title    = {A Computational Semantics for Natural Language},
}
@proceedings{acl85,
  address   = {Chicago, IL},
  editor    = {Mann, William C.},
  publisher = {acl},
  title     = {Proceedings of the {Twenty-Third Annual Meeting
               of the Association for Computational Linguistics}},
  url       = {http://irgendwo.de},
  urldate   = {2021-02-15},
  year      = {1985},
}
\end{filecontents}
\begin{filecontents}{bookparent.dbx}
\DeclareDatamodelEntryfields[book]{
  booktitle}

\DeclareDatamodelFields[type=field,datatype=date]{
   urldate}
\DeclareDatamodelEntryfields{urldate}

\ResetDatamodelConstraints

\DeclareDatamodelConstraints[
  article,
  book,
  inbook,
  bookinbook,
  suppbook,
  booklet,
  collection,
  incollection,
  suppcollection,
  manual,
  misc,
  mvbook,
  mvcollection,
  online,
  patent,
  periodical,
  suppperiodical,
  proceedings,
  inproceedings,
  reference,
  inreference,
  report,
  set,
  thesis,
  unpublished]{
    \constraint[type=mandatory]{
      \constraintfieldsxor{
        \constraintfield{date}
        \constraintfield{year}
      }
    }
    % if there is an URL then there should be a urldate field.
    \constraint[type=conditional]{
      \antecedent[quantifier=one]{
        \constraintfield{url}
      }
      \consequent[quantifier=all]{
        \constraintfield{urlyear}
        \constraintfield{urlmonth}
        \constraintfield{urlday}
      }
    }
  }
\end{filecontents}

\usepackage[
  natbib=true,
  backend=biber,
  datamodel=bookparent,
]{biblatex}
\addbibresource{\jobname.bib}

\begin{document}
\autocite{CP85a-nirgendwo,CP85a-irgendwo}

\printbibliography
\end{document}

Does not give any warnings on a biber -V run, because all entries have a url and urldate.

In particular CP85a-nirgendwo does not generate a warning, even though you would like to see one for that entry. Since data model verification happens at a point where inherited data is already resolved, there is no way to warn about CP85a-nirgendwo since it does have a url and urldate (the data model verification does not know that one was inherited and the other was given in the entry itself). If you need to be able to treat inherited fields differently from fields given directly in the entry, you may want to open a feature request at https://github.com/plk/biber/issues.

1
  • Thanks! Well, maybe the feature request would be overkill. It is just for very careful checking of the bibs. Maybe I am overdoing here. Commented Feb 17, 2021 at 9:30

You must log in to answer this question.

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