citation-style-language / schema

Citation Style Language schema
https://citationstyles.org/
MIT License
187 stars 60 forks source link

Add a test condition context="citation" / context="bibliography" #80

Open fbennett opened 13 years ago

fbennett commented 13 years ago

In note styles, the formatting of entries in cs:citation and cs:bibliography is often roughly the same, with some small adjustments to, say, the formatting of names.

If the style is composed as a set of nested groups (the simplest way to strictly avoid extraneous spaces and hanging punctuation), the elements that require tweaking can end up deep inside the nesting hierarchy. Currently the only way to create separate "citation" and "bibliography" versions of the hierarchy is to create separate versions of any macros that (eventually) call elements that need tweaking. In a complex style, that leads to a lot of cutting and pasting, and unmaintainable code.

If a test for context were available, the macros from which the hierarchy is composed could be made smarter, and the same hierarchy (encapsulated in a single macro) could be used in both contexts.

fbennett commented 13 years ago

Here is a patch for the schema change, from the MLZ branch. It won't apply cleanly to official CSL 1.0, but shows what what would be added:

--- a/csl.rnc
+++ b/csl.rnc
@@ -1033,6 +1033,10 @@ div {
         attribute jurisdiction {
             list { jurisdictions+ }
         }
+      |
+        ## Tests whether the statement containing the condition is being
+        ## executed inside cs:citation or cs:bibliography
+        attribute context { "citation" | "bibliography" }
     )
 }
bdarcus commented 13 years ago

Can you point to a style that demonstrates this problem? On Sep 29, 2011 5:11 PM, "Frank Bennett" < reply@reply.github.com> wrote:

In note styles, the formatting of entries in cs:citation and cs:bibliography is often roughly the same, with some small adjustments to, say, the formatting of names.

If the style is composed as a set of nested groups, which is the simplest way to strictly avoid extraneous spaces and hanging punctuation, the elements that require tweaking can end up deep inside the nesting hierarchy. Currently the only way to create separate "citation" and "bibliography" versions of the hierarchy and of any macros that (eventually) call elements that need tweaking. In a complex style, that leads to a lot of cutting an pasting, and unmaintainable code.

If a test for context were available, the macros from which the hierarchy is composed could be made smarter, and the same hierarchy (encapsulated in a single macro) could be used in both contexts.

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

fbennett commented 13 years ago

I've run into it with OSCOLA, which is validated against a schema that prohibits leading and tailing space on affixes:

https://github.com/fbennett/mlz-styles/blob/master/mlz-oscola.csl

It's currently done with the cut-paste-and-edit approach. I've added the "context" test attribute to the extended schema, and will be refactoring it in a more compact form in a few days.

rmzelle commented 13 years ago

Fine with me.

The only question I have is whether this would complicate automated style editing.

rmzelle commented 13 years ago

@adam3smith, do you see (a lot of) value in this, seeing as you're our most seasoned style editor?

adam3smith commented 13 years ago

I'd yield to Frank on this. I don't edit legal styles, and those are by far the most complicated note-based style. For the styles I edit (where all note-based styles are, essentially, CMoS derivatives) there is no need for and very little value in this.

bdarcus commented 13 years ago

I generally have the same reaction as @rmzelle - seems reasonable enough, but I do wonder if it might have negative unintended consequences, and whether the potential benefits outweigh the potential costs?

denismaier commented 4 years ago

So, 9 years later. What should we do with this? Any new thoughts? (By the way, I suggest we add labels like "deferred" or "needs more discussion" for issues that we currently can not solve.)