Citation Style Language

XPath or other test value of text in CSL?

Greeting,
I’m looking to try and include content from certain notes within Zotero in my CSL outputs. I’m wondering if this is possible.

As I understand it, the CSL for APA annotated bibliography uses the Zotero Extra field. I want to do something different. I want to have the first line of my note be __annotation and then have it included in the annotated bibliography output. Then I can still keep the Extra field clean for other CSL variables as needed, and my annotation in a clean note.

something like

check if notes exists
if exists, then check first line, if equal to __annotation
then enclude
else
exit

My thought was that there might be the capability of checking values with CSL. It seems there is limited support for this via cs:choose.

Is there any way to achieve what I am looking to do within the parameters of CSL?

CSL hasn’t an option like that, but what about this: kb:item types and fields [Zotero Documentation]

You mean like a custom field inserted into the Extra field? That is an interesting idea, it might technically work. The Extra field is not a great place to write notes as the UI for the field is small.

Zotero notes aren’t accessible to CSL at all (and it’d be tricky to do so given Zotero’s data model), so this wouldn’t be possible regardless of CSL’s capabilities to test text content (which we’re also almost certainly not going to add)

Not that I knew how to do that, but @retorquere’s Zotero BBT plugin has an option to add bibtex citekeys to the CSL JSON on export by patching the note/extra field. Maybe you could do something similar if you really want to go down that road, but I fear that will be a rough ride.

If you export as better csl json/yaml, the ID of the entries is the bbt citekey. That doesn’t require anything special, that’s just the default behavior.

Edit: ah, that’s not what was requested. BBT JSON will give you everything. You can even fetch it via pull export so you don’t have to do manual exports.

I’ve been probably unclear. Sorry. I was talking about this option: Hidden preferences :: Better BibTeX for Zotero

I was thinking one could write a plugin that adds certain notes to the notes variable.

It is possible to do this in a plugin you can build, but BBT already does everything that I think you want here. If you want CSL+,use better csl with a postscript. If you just want all the entry data, including the notes,but not necessarily in CSL format,use betterbibtex json.

@retorquere I should clarify here. The original question was about the ability to implement annotated bibliographies via Zotero using the CSL XML style sheets. The goal output of this question was to use notes attached to Zotero records as the annotations in an annotated bibliography. We could either directly tag annotations in zotero with a tag, or we could start the annotation with a keyword such as __annotation to differentiate the target note to include from other notes attached to the Zotero record. The goal here was to see if the CSL XML would support that, so that annotated bibliographies could be exported to any of the document types that Zotero via CSL supports. For reasons of ease of editing during collaboration, we wanted to stay away from the Zotero Extra field (though we do use that for other CSL variables as well).

Independently of the original question I wrote @retorquere to ask if there was a way to export essentially the same data as JSON. I am currently working with the devs of Hugo-Cite a theme/addon for Hugo which reads CSL-JSON. However, I have several projects which use keywords and annotations and I would like those to appear in the JSON file used for creating references, hence the CSL-JSON+ comment (I could then use the same JSON file for sorting, filtering, and generating references). The CSL-JSON would only be output for web-based presentations, not the full range of documents Zotero supports. So I see these as two seperate questions, albeit related in the sense that I’m generating content from the same source data.

BBT CSL JSON can do that with a postscript, but you can just hack up the Zotero CSL-JSON translator if you want to do without. I see no need for a full plugin here - a modified translator gets you 99% of the way,the only thing you’d be missing is automatic install/upgrade/rreinstall after a translators reset.