Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about combining multiple conditions #4882

Open
danmichaelo opened this issue Jun 23, 2020 · 1 comment
Open

Question about combining multiple conditions #4882

danmichaelo opened this issue Jun 23, 2020 · 1 comment

Comments

@danmichaelo
Copy link

@danmichaelo danmichaelo commented Jun 23, 2020

Hope this is the right place to ask questions, CONTRIBUTING.md seemed to suggest it is.

I'm working on an update to universitetet-i-oslo-rettsvitenskap.csl and struggle a bit with combinations of conditions. I'm also quite new to CSL. My goal is to format the locator in a special way if (locator is "section" OR "paragraph") AND (type is "legislation" OR "legal_case" OR "bill").

This matches too much:

<if locator="section paragraph" type="legislation legal_case" match="any">

(for instance locator=section, type=book)

While this matches too little / nothing(?):

<if locator="section paragraph" type="legislation legal_case" match="all">

Is there a way I can express this without resorting to multiple levels of s and having to repeat the <else> section? Here's my full macro at the moment:

  <macro name="locator">
    <choose>
      <if locator="section paragraph" type="legislation legal_case">
        <text variable="locator" prefix=" § "/>
      </if>
      <else>
        <group delimiter=" ">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </else>
    </choose>
  </macro>
@adam3smith
Copy link
Member

@adam3smith adam3smith commented Jun 23, 2020

(I'd generally put "how to" questions on our discourse forum discourse.citationstyles.org/ but it doesn't matter terribly).
There's no great solution to this, no; you can't combine AND and OR in a single condition, so some repetition is unavoidable.

I think the shortest version is

  <macro name="locator">
    <choose>
      <if type="legislation legal_case" match="none">
        <group delimiter=" ">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </if>
     <else-if locator="section paragraph" match="any">
       <text variable="locator" prefix=" § "/>
      </else-if>
      <else>
        <group delimiter=" ">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </else>
    </choose>
  </macro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.