# linking the DOI variable

**URL:** <https://discourse.citationstyles.org/t/linking-the-doi-variable/1074>\
**Category:** CSL Development\
**Created:** [February 16, 2012, 5:02pm UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074 "2012-02-16T17:02:29Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [February 22, 2012, 12:11am UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074/21 "2012-02-22T00:11:57Z")

</div>

> Agreed. Even though we have a custom processor that’s directly compiled with the app, it is indeed the way things are split on our end: the processor code just takes whatever data is handed to it at face value, with no extra processing. It’s up to my Papers-to-CSL translation layer to return a proper value upon request of a CSL variable.
> 
> It makes much more sense to do any parsing at the client level, since the data is also displayed to the user, and might as well be cleaned up for that purpose as well.
> 
> charles

I agree that the processor should assume clean input. The only  
extension I have in mind is to (blindly) link the DOI with an anchor  
in HTML output (by adding the HTML anchor tags as a wrapper, with the  
stub prefix on the href of the anchor).

Frank

---

<div class="post-metadata">

**Author:** ![Charles\_Parnot](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Charles\_Parnot](https://discourse.citationstyles.org/u/Charles_Parnot)\
**Post date:** [February 22, 2012, 12:15am UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074/22 "2012-02-22T00:15:08Z")

</div>

Ah, OK, sorry, I misunderstood as well 🙂 It’s still unclear to me what you have in mind. Could you give an example of what the CSL would look like?

charles

---

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [February 22, 2012, 12:48am UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074/23 "2012-02-22T00:48:19Z")

</div>

> Ah, OK, sorry, I misunderstood as well 🙂 It’s still unclear to me what you have in mind. Could you give an example of what the CSL would look like?
> 
> charles

As a first step, I’m just thinking of the easy case, where a DOI or  
URL is rendered in the citation output. One could just apply links  
automatically by default, with a processor toggle to turn links off if  
they are not desired. There wouldn’t be any impact on CSL.

I’ll be looking at HTML output first, just because I know the markup  
for anchors there. Once I’ve gotten the processor to provide the  
markup in HTML, it should be simple enough for someone who knows RTF  
syntax to add a similar extension there.

Adding links to arbitrary portions of the output (like the title, as  
Bruce suggests) would be a next step, dependent on extensions to CSL.

Frank

---

<div class="post-metadata">

**Author:** ![andrea\_rossato2](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@andrea\_rossato2](https://discourse.citationstyles.org/u/andrea_rossato2)\
**Post date:** [February 24, 2012, 8:44am UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074/24 "2012-02-24T08:44:08Z")

</div>

Frank Bennett \<@Frank\_Bennett\> writes:

> > Ah, OK, sorry, I misunderstood as well 🙂 It’s still unclear to me what you have in mind. Could you give an example of what the CSL would look like?
> > 
> > charles
> 
> As a first step, I’m just thinking of the easy case, where a DOI or  
> URL is rendered in the citation output. One could just apply links  
> automatically by default, with a processor toggle to turn links off if  
> they are not desired. There wouldn’t be any impact on CSL.
> 
> I’ll be looking at HTML output first, just because I know the markup  
> for anchors there. Once I’ve gotten the processor to provide the  
> markup in HTML, it should be simple enough for someone who knows RTF  
> syntax to add a similar extension there.
> 
> Adding links to arbitrary portions of the output (like the title, as  
> Bruce suggests) would be a next step, dependent on extensions to CSL.

A possible solution for the first simple step would be to inspect the  
DOI variable:

- if prefixed by “doi:” I could produce:  
[10.1038/171737a0](http://dx.doi.org/10.1038/171737a0)

- if prefixed by “[http://dx.doi.org/](http://dx.doi.org/)” I could produce:  
[http://dx.doi.org/10.1038/171737a0](http://dx.doi.org/10.1038/171737a0)

- if not prefixed by I could produce plain text.

Would that make sense?

A new cs:link element I believe should be the possible next step. In  
this case affixes could be included in the rendered (linked) element. If  
we use a link attribute for the cs:text element, affixes should instead  
be excluded from the linked text, right?

Andrea

---

<div class="post-metadata">

**Author:** ![Frank\_Bennett](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/frank_bennett/32/198_2.png) [@Frank\_Bennett](https://discourse.citationstyles.org/u/Frank_Bennett)\
**Post date:** [February 24, 2012, 9:18am UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074/25 "2012-02-24T09:18:58Z")

</div>

> Frank Bennett \<@Frank\_Bennett\> writes:
> 
> > > Ah, OK, sorry, I misunderstood as well 🙂 It’s still unclear to me what you have in mind. Could you give an example of what the CSL would look like?
> > > 
> > > charles
> > 
> > As a first step, I’m just thinking of the easy case, where a DOI or  
> > URL is rendered in the citation output. One could just apply links  
> > automatically by default, with a processor toggle to turn links off if  
> > they are not desired. There wouldn’t be any impact on CSL.
> > 
> > I’ll be looking at HTML output first, just because I know the markup  
> > for anchors there. Once I’ve gotten the processor to provide the  
> > markup in HTML, it should be simple enough for someone who knows RTF  
> > syntax to add a similar extension there.
> > 
> > Adding links to arbitrary portions of the output (like the title, as  
> > Bruce suggests) would be a next step, dependent on extensions to CSL.
> 
> A possible solution for the first simple step would be to inspect the  
> DOI variable:
> 
> - if prefixed by “doi:” I could produce:  
> [10.1038/171737a0](http://dx.doi.org/10.1038/171737a0)
> 
> - if prefixed by “[http://dx.doi.org/](http://dx.doi.org/)” I could produce:  
> [http://dx.doi.org/10.1038/171737a0](http://dx.doi.org/10.1038/171737a0)
> 
> - if not prefixed by I could produce plain text.
> 
> Would that make sense?

Could we just assume that the field contains a valid DOI, since that’s  
what the field is meant for? Then we could just prefix it with  
[http://dx.doi.org/](http://dx.doi.org/) in the href of the anchor, and make the unprefixed  
field value the content of the anchor. It will break if there is a  
“doi:” or “[http://dx.doi.org/](http://dx.doi.org/)” prefix written into the field, but the  
breakage will encourage people to clean up their data.

---

<div class="post-metadata">

**Author:** ![Rintze\_Zelle](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/rintze_zelle/32/175_2.png) [@Rintze\_Zelle](https://discourse.citationstyles.org/u/Rintze_Zelle)\
**Post date:** [February 24, 2012, 2:17pm UTC](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074/26 "2012-02-24T14:17:32Z")

</div>

Fine with me, as long as the CSL processor wrapper (e.g. Zotero and its  
import/web/search translators) helps with the clean up.

RintzeOn Fri, Feb 24, 2012 at 4:18 AM, Frank Bennett \<@Frank\_Bennett\>wrote:

[Previous page](https://discourse.citationstyles.org/t/linking-the-doi-variable/1074.md?page=1)
