# XPath or other test value of text in CSL?

**URL:** <https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729>\
**Category:** Uncategorized\
**Created:** [June 17, 2021, 11:39am UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729 "2021-06-17T11:39:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![HughP](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/hughp/32/233_2.png) [@HughP](https://discourse.citationstyles.org/u/HughP)\
**Post date:** [June 17, 2021, 11:39am UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/1 "2021-06-17T11:39:43Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 17, 2021, 12:26pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/2 "2021-06-17T12:26:44Z")

</div>

CSL hasn’t an option like that, but what about this: [kb:item types and fields [Zotero Documentation]](https://www.zotero.org/support/kb/item_types_and_fields#citing_fields_from_extra)

---

<div class="post-metadata">

**Author:** ![HughP](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/hughp/32/233_2.png) [@HughP](https://discourse.citationstyles.org/u/HughP)\
**Post date:** [June 17, 2021, 2:29pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/3 "2021-06-17T14:29:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Karcher](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/sebastian_karcher/32/176_2.png) [@Sebastian\_Karcher](https://discourse.citationstyles.org/u/Sebastian_Karcher)\
**Post date:** [June 17, 2021, 3:04pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/4 "2021-06-17T15:04:42Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 17, 2021, 9:56pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/5 "2021-06-17T21:56:39Z")

</div>

> [@Sebastian\_Karcher](#):
>
> Zotero notes aren’t accessible to CSL at all (and it’d be tricky to do so given Zotero’s data model),

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.

---

<div class="post-metadata">

**Author:** ![retorquere](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/retorquere/32/203_2.png) [@retorquere](https://discourse.citationstyles.org/u/retorquere)\
**Post date:** [June 17, 2021, 10:18pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/6 "2021-06-17T22:18:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 17, 2021, 10:41pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/7 "2021-06-17T22:41:41Z")

</div>

I’ve been probably unclear. Sorry. I was talking about this option: [Hidden preferences :: Better BibTeX for Zotero](https://retorque.re/zotero-better-bibtex/installation/preferences/hidden-preferences/#citeprocnotecitekey)

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

---

<div class="post-metadata">

**Author:** ![retorquere](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/retorquere/32/203_2.png) [@retorquere](https://discourse.citationstyles.org/u/retorquere)\
**Post date:** [June 18, 2021, 11:44am UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/8 "2021-06-18T11:44:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HughP](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/hughp/32/233_2.png) [@HughP](https://discourse.citationstyles.org/u/HughP)\
**Post date:** [June 18, 2021, 5:33pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/9 "2021-06-18T17:33:43Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![retorquere](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/retorquere/32/203_2.png) [@retorquere](https://discourse.citationstyles.org/u/retorquere)\
**Post date:** [June 18, 2021, 6:55pm UTC](https://discourse.citationstyles.org/t/xpath-or-other-test-value-of-text-in-csl/1729/10 "2021-06-18T18:55:16Z")

</div>

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.
