Syntax proposal: replace match="none" with -<name> #107

Closed
fbennett opened this Issue Jan 19, 2013 · 4 comments

Comments

Projects
None yet
3 participants
@fbennett
Member

fbennett commented Jan 19, 2013

The complexity of styles is increased when there is a need to combine match and non-match conditions. For example, suppose that, for the webpage type only, the accessed date should be used as a fallback where no issued value is present. Logically, this can be expressed as a single statement with a single fallback:

  • If item is type webpage and issued is nil, use accessed;
  • Otherwise use issued.

In current CSL, the test for webpage and the test for a nil issued variable cannot coexist on a single condition node. A "year-date" macro populated across six styles [1] implements it with the following code:

  <macro name="year-date">
    <choose>
      <if type="webpage">
        <choose>
          <if variable="issued">
            <date variable="issued">
              <date-part name="year"/>
            </date>
          </if>
          <else>
            <date variable="accessed">
              <date-part name="year"/>
            </date>
          </else>
        </choose>
      </if>
      <else>
        <date variable="issued">
          <date-part name="year"/>
        </date>
      </else>
    </choose>
  </macro>

If non-match markup syntax were available on the elements of attribute lists, the code above could be reduced to something like this:

  <macro name="year-date">
    <choose>
      <if type="webpage" variable="-issued" match="all">
        <date variable="accessed">
          <date-part name="year"/>
        </date>
      </if>
      <else>
        <date variable="issued">
          <date-part name="year"/>
        </date>
      </else>
    </choose>
  </macro>

The first sample does not contain a match="none" condition, but logically it is implementing a "none" match by nesting conditions and replicating the else condition twice.

[1] The styles that use this particular macro (or a more elaborate extension of it) are:

hwr-berlin.csl
stuttgart-media-university.csl
tgm-wien-diplom.csl
tu-wien-dissertation.csl
un-eclac-cepal-english.csl
un-eclac-cepal-spanish.csl
@bdarcus

This comment has been minimized.

Show comment Hide comment
@bdarcus

bdarcus Jan 19, 2013

Member

When we were designing a first release, we should have considered this
option. But is the cost of adding this feature really worth the benefit at
this point?

I tend to think small improvements in brevity are not worth the cost of
breaking compatibility.

If other actual implementors believe differently, I'd ask a practical
question: do we know the programming logic to cleanly convert
back-and-forth between these two representations?

Finally, the example doesn't include a match="none" attribute (?), so I'm a
little confused.

On Sat, Jan 19, 2013 at 6:18 AM, Frank Bennett notifications@github.comwrote:

The complexity of styles is increased when there is a need to combine
match and non-match conditions. Currently, this requires nesting and
replication of conditions, like this:

If non-match markup syntax were available on the elements of attribute
lists, the code above could be reduced to something like this:

... which is a bit easier to follow.


Reply to this email directly or view it on GitHubhttps://github.com/citation-style-language/schema/issues/107.

Member

bdarcus commented Jan 19, 2013

When we were designing a first release, we should have considered this
option. But is the cost of adding this feature really worth the benefit at
this point?

I tend to think small improvements in brevity are not worth the cost of
breaking compatibility.

If other actual implementors believe differently, I'd ask a practical
question: do we know the programming logic to cleanly convert
back-and-forth between these two representations?

Finally, the example doesn't include a match="none" attribute (?), so I'm a
little confused.

On Sat, Jan 19, 2013 at 6:18 AM, Frank Bennett notifications@github.comwrote:

The complexity of styles is increased when there is a need to combine
match and non-match conditions. Currently, this requires nesting and
replication of conditions, like this:

If non-match markup syntax were available on the elements of attribute
lists, the code above could be reduced to something like this:

... which is a bit easier to follow.


Reply to this email directly or view it on GitHubhttps://github.com/citation-style-language/schema/issues/107.

@rmzelle

This comment has been minimized.

Show comment Hide comment
@rmzelle

rmzelle Jan 19, 2013

Member

As @bdarcus, I don't quite follow the example.

Member

rmzelle commented Jan 19, 2013

As @bdarcus, I don't quite follow the example.

@fbennett

This comment has been minimized.

Show comment Hide comment
@fbennett

fbennett Jan 19, 2013

Member

I've replaced the example with a snippet of code from a repository style.

Member

fbennett commented Jan 19, 2013

I've replaced the example with a snippet of code from a repository style.

@fbennett

This comment has been minimized.

Show comment Hide comment
@fbennett

fbennett Jan 31, 2013

Member

About conversion (Bruce's question), in forward migration you could either continue to support match="none", or you could append "-" to the appropriate list elements on the match="none" node. Backward migration would not be practical.

Member

fbennett commented Jan 31, 2013

About conversion (Bruce's question), in forward migration you could either continue to support match="none", or you could append "-" to the appropriate list elements on the match="none" node. Backward migration would not be practical.

@fbennett fbennett closed this Feb 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment