Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io
Other
305 stars 85 forks source link

Call jurisdiction country code in csl file #161

Closed georgd closed 4 years ago

georgd commented 4 years ago

Is there a way to call the country code of a jurisdiction in a style file? The IBFD requires legal sources to be prefixed with the country code of the jurisdiction. Currently, I’m testing for each jurisdiction and return the corresponding code as can be seen in https://github.com/georgd/jm-styles/blob/304816a81b7126074ec62137e3145025a5ab77c5/jm-ibfd-with-page-label.csl#L62-L66 ...

This could be fine, but then it won’t work with sub-jurisdictions. E.g. an item with "jurisdiction": "at:innsbruck:feldkirch" won’t return true when testing for at. This is fine in principle, as at is a jurisdiction in its own right. (Perhaps something like a starred test could be introduced like <if jurisdiction="at*"> to test for jurisdiction at and any sub-jurisdiction?)

fbennett commented 4 years ago

Yes! Just use this:

<text variable="jurisdiction" form="short"/>
georgd commented 4 years ago

Two issues arise here:

A test to illustrate this:

>>===== MODE =====>>
citation
<<===== MODE =====<<

>>===== RESULT =====>>
..[0] AT
>>[1] AT
<<===== RESULT =====<<

>>===== CITATIONS =====>>
[
    [
        {
            "citationID": "CITATION-1", 
            "citationItems": [
                {
                    "id": "ITEM-1"
                }
            ], 
            "properties": {
                "noteIndex": 1
            }
        }, 
        [], 
        []
    ],
    [
        {
            "citationID": "CITATION-2", 
            "citationItems": [
                {
                    "id": "ITEM-2"
                }
            ], 
            "properties": {
                "noteIndex": 2
            }
        }, 
        [
            [
                "CITATION-1", 
                1
            ] 
        ], 
        []
    ]
]
<<===== CITATIONS =====<<

>>===== CSL =====>>
<style 
      xmlns="http://purl.org/net/xbiblio/csl"
      class="note"
      version="1.1mlz1">
  <info>
    <title>Test fixture</title>
    <id>http://citationstyles.org/tests/fixture</id>
    <link href="http://citationstyles.org/tests/fixture" rel="self"/>
    <link href="http://citationstyles.org/documentation/text" rel="documentation"/>
    <category citation-format="author-date"/>
    <updated>2014-04-30T13:19:38+00:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <citation>
    <layout>
      <text variable="jurisdiction" form="short"/>
    </layout>
  </citation>
</style>
<<===== CSL =====<<

>>===== INPUT =====>>
[
    {
        "id": "ITEM-1", 
        "type": "legal_case",
        "authority": "ogh",
        "jurisdiction": "at"
    },
    {
        "id": "ITEM-2", 
        "type": "legal_case",
        "authority": "lg",
        "jurisdiction": "at:innsbruck:feldkirch"
    }
]
<<===== INPUT =====<<
fbennett commented 4 years ago

Sorry, that was incomplete. You also have a variable "country" to work with in the same way. It may serve your use case to just render it without form="short" and with text-case set to uppercase (I forget the exact argument).

On Friday, October 2, 2020, Georg Mayr-Duffner notifications@github.com wrote:

Two issues arise here:

  • like above, sub-jurisdictions are getting in the way: while for all, say, Austrian legal cases I want the code "AT" to appear in the citation, calling the jurisdiction variable (as expected) returns the abbreviation of the very subjurisdiction.
  • looking at the abbreviation sources reveals that where the top-most level jurisdiction is not used in court abbreviations, there’s no abbrev at all. So, nothing is rendered by this call. What’s more, this abbrev, if it exists, is not necessarily the country code as expected for marking the country.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Juris-M/citeproc-js/issues/161#issuecomment-702538384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAASMSQZX7GT7NE4CKSSCI3SIVSWLANCNFSM4SBBCBDQ .

georgd commented 4 years ago

Oh, that’s really neat. Just what I need :)