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 variables_TitleShortOnShortTitleNoTitleCondition.txt #29

Open
jgm opened this issue Jun 17, 2020 · 5 comments
Open

Question about variables_TitleShortOnShortTitleNoTitleCondition.txt #29

jgm opened this issue Jun 17, 2020 · 5 comments

Comments

@jgm
Copy link

jgm commented Jun 17, 2020

I have another test case I can't understand.
In this case the style is

  <citation>
    <layout>
      <choose>
        <if variable="title-short">
          <group delimiter=" ">
            <text variable="title"/>
            <group>
              <text value="has title-short"/>
            </group>
          </group>
        </if>
        <else>
          <group delimiter=" ">
            <text variable="title"/>
            <group>
              <text value="does not have title-short"/>
            </group>
          </group>
        </else>
      </choose>
    </layout>
  </citation>

There are three citations. The first is to a reference with title-short, the second to a reference with title but not title-short, the third to a reference with neither title nor title-short.

My processor gives no output for the third citation. Why? Because the spec for group says:

cs:group implicitly acts as a conditional: cs:group and its child elements are suppressed if a) at least one rendering element in cs:group calls a variable (either directly or via a macro), and b) all variables that are called are empty.

It seems to me that the criterion for suppression is met in this case for the third item. The outer group calls a variable (title), and it is empty. So the whole group and its child group should be suppressed, according to the spec, right? However, the expected result in the test case is:

My Long Title 1 has title-short
My Long Title 2 does not have title-short
does not have title-short

What am I missing?

@denismaier
Copy link
Member

Looks wrong to me as well.
Perhaps the inner group hides its contents from the outer group so the suppression mechanism can't be applied. @fbennett ?
Dont know if there's something in the spec that allows that.

@denismaier
Copy link
Member

Hmm, this here works as expected:

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

>>==== RESULT ====>>
My Long Title 1 has title-short
My Long Title 2 does not have title-short
does not have title-short
<<==== RESULT ====<<

>>==== CITATION-ITEMS ====>>
[
    [
        {
            "id": "ITEM-1"
        }
    ],
    [
        {
            "id": "ITEM-2"
        }
    ],
    [
        {
            "id": "ITEM-3"
        }
    ]
]
<<==== CITATION-ITEMS ====<<

>>==== CSL ====>>
<style 
      xmlns="http://purl.org/net/xbiblio/csl"
      class="note"
      version="1.0">
  <info>
    <id />
    <title />
    <updated>2009-08-10T04:49:00+09:00</updated>
  </info>
  <citation>
    <layout>
      <choose>
        <if variable="title-short">
          <group delimiter=" ">
            <text variable="title"/>
            <group>
              <text value="has title-short"/>
            </group>
          </group>
        </if>
        <else>
          <group delimiter=" ">
            <text variable="title"/>
			<text value="does not have title-short"/>
          </group>
        </else>
      </choose>
    </layout>
  </citation>
</style>
<<==== CSL ====<<

>>==== INPUT ====>>
[
  {
    "id": "ITEM-1",
    "title": "My Long Title 1",
    "title-short": "My Short Title",
    "type": "book"
  },
  {
    "id": "ITEM-2",
    "title": "My Long Title 2",
    "type": "book"
  },
  {
    "id": "ITEM-3",
    "type": "book"
  }
]
<<==== INPUT ====<<

This here as well:

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

>>==== RESULT ====>>
My Long Title 1 has title-short
My Long Title 2 does not have title-short
does not have title-short
<<==== RESULT ====<<

>>==== CITATION-ITEMS ====>>
[
    [
        {
            "id": "ITEM-1"
        }
    ],
    [
        {
            "id": "ITEM-2"
        }
    ],
    [
        {
            "id": "ITEM-3"
        }
    ]
]
<<==== CITATION-ITEMS ====<<

>>==== CSL ====>>
<style 
      xmlns="http://purl.org/net/xbiblio/csl"
      class="note"
      version="1.0">
  <info>
    <id />
    <title />
    <updated>2009-08-10T04:49:00+09:00</updated>
  </info>
  <citation>
    <layout>
      <choose>
        <if variable="title-short">
          <group delimiter=" ">
            <text variable="title"/>
            <group>
              <text value="has title-short"/>
            </group>
          </group>
        </if>
        <else>
          <group delimiter=" ">
            <text variable="title"/>
            <group>
              <text value="does not have title-short"/>
              <text variable="title"/>
            </group>
          </group>
        </else>
      </choose>
    </layout>
  </citation>
</style>
<<==== CSL ====<<

>>==== INPUT ====>>
[
  {
    "id": "ITEM-1",
    "title": "My Long Title 1",
    "title-short": "My Short Title",
    "type": "book"
  },
  {
    "id": "ITEM-2",
    "title": "My Long Title 2",
    "type": "book"
  },
  {
    "id": "ITEM-3",
    "type": "book"
  }
]
<<==== INPUT ====<<

Here, the suppression logic seems to work: The inner group is suppressed and that the outer group gets suppressed as well.

@bdarcus
Copy link
Member

bdarcus commented Jun 18, 2020 via email

@denismaier
Copy link
Member

Can you clarify what you mean by "works"? In what context?

That tests fail as expected when using the citeproc test runner.

@adam3smith
Copy link
Member

I agree the test behavior is clearly contrary to specs.

The reason for the test behavior is that the group "protects" the included text value element. (The reason @denismaier 's modifed test behaves differently is that the lower-level group now also includes a variable, so that renders empty on its own count.).

I somewhat recall a lengthy discussion about the appropriate behavior for group element suppression on discourse and we should look closely at functional requirements and existing styles to determine if the test or the spec should be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants