Test if "date-parts" for variable "accessed" are defined

I have a (automatically generated) bibliography with dozens of entries where
- the field "URL" is defined,
- but no fields for "date-parts" under the "accessed" variable
are available.

I use the CSL style file "zeitschrift-fur-kunstgeschichte.csl". The code for printing URLs (line 331 onwards) is
```
choose
if variable="URL" match="any"
group
text variable="URL" prefix=", "/
text term="accessed" prefix=" ("/
date variable="accessed" prefix=" " delimiter="." suffix=")"
date-part name="day"/
date-part name="month" form="numeric"/
date-part name="year"/
/date
/group
/if
/choose
```
As a consequence, in a case as above, a bibliography entry will look like

"Bonito, Virginia Anne, The St Anne Altar in Sant’ Agostino in Rome: A New Discovery, in: The Burlington Magazine 122/933, 1980, S. 805–812, http://www.jstor.org/stable/880160 (letzter Zugriff am.",

because the "URL" is given (while the date-part elements are not).

Now I'd like to leave out the URL altogether in cases where no access date is defined.

I tried to add a second test if the variable "assessed" was defined:
```
choose
if variable="URL" match="any"
if variable="accessed" match="any"
group
...
```

However, this doesn't work: the URL will never be printed, even if an access date is defined.

My question: How would I code the additional test correctly? Any help would be much appreciated.
  • Move the URL outside of the group. If there is no URL, it won’t print. Then, leave the test for URL with the group that just contains the term and accessed variable. When accessed doesn’t exist, nothing in the group (prefixes and term included) will be shown.
  • Thanks @bwiernik, but I'm not sure that I get it...

    The problem is: In the cases of interest, a URL IS defined (while there is no date of access), but I don't want the URL to be printed.

    If I moved 'text variable="URL" prefix=", "/' out of the group, it would still be printed?, which I don't want.

    It would be great if there existed an analogous construct to a 'group', which would be printed only if EVERY variable inside of it was filled (unlike the regular 'group', which will print if at least ONE variable is defined).

  • First, I'm not sure why you would want to not show the URL if there is no accessed date. The URL is almost certainly more useful than the accessed date (which is why many styles like Chicago or APA don't require accessed dates at all but do want URLs). While most items imported into Zotero that have URLS will also accessed dates, I'd recommend having your style always show URL and then only show accessed if URL is present.

    That said, if you do want to show URL and accessed only if both are present, then change your first if statement in your original post to be:
    if variable="URL accessed" match="all"
  • Thank you, it works as intended!

    As to your first question: A simple answer could be that the style as such - if it is the correct representation of the journal's guidelines - doesn't print URLs for, say, journal articles. If it did, I hadn't encountered the bug. =)
Sign In or Register to comment.