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

Style syntax for @related variables #357

Open
bwiernik opened this issue Aug 12, 2020 · 42 comments · May be fixed by #375
Open

Style syntax for @related variables #357

bwiernik opened this issue Aug 12, 2020 · 42 comments · May be fixed by #375
Assignees
Milestone

Comments

@bwiernik
Copy link
Member

We need to write the style syntax for calling related items.

@bwiernik bwiernik added this to the CSL 1.1 milestone Aug 12, 2020
@bdarcus
Copy link
Member

bdarcus commented Aug 12, 2020

Isn't it just a related attribute on the appropriate rendering nodes?

@bwiernik
Copy link
Member Author

That's not in the schema currently

@denismaier
Copy link
Member

Basically, that should just be a new atttibute related on cs:date, cs:names, cs:text, and cs:number? Correct?

@bwiernik
Copy link
Member Author

That's all the rendering elements except choose, right?

@bwiernik
Copy link
Member Author

We might consider allowing it on cs:group and cs:macro and making it inheritable?

@denismaier
Copy link
Member

We might consider allowing it on cs:group and cs:macro and making it inheritable?

So, to have text variable="title" in a macro/group, but have it expanded to text variable="title" related="original"?

@bwiernik
Copy link
Member Author

Yeah, thinking of something like:

<macro name="reviewed" related="reviewed">
  <group delimiter=", ">
    <text variable="title"/>
    <names variable="author">
      <label form="verb" suffix=" "/>
      <name/>
      <substitute>
        <names variable="editor"/>
       </substitute>
    </names>
    <data variable="issued"/>
  </group>
</macro>

versus requiring @related to be set on each variable individually.

@bwiernik
Copy link
Member Author

That would also make it clear what should happen when this appears:
<text macro="contributors" related="original"/>

@denismaier
Copy link
Member

Good idea.

@denismaier
Copy link
Member

What if the macro definition has a related attribute and the macro call as well?

@bwiernik
Copy link
Member Author

The general inheritance rules are that a lower-level specification overrides an inherited value from higher-up. I think that's fine here. If that shouldn't happen, the style should be written accordingly.

@denismaier
Copy link
Member

How would you call a variable with the standard relationship? related="item"?
E.g., if you have a macro with related="original", but one variable would refer to a variable from the item itself.

@bwiernik
Copy link
Member Author

Is that necessary?

@bwiernik
Copy link
Member Author

I'm not sure that's really necessary, but that could be accomplished by not setting related on the macro, but instead setting it lower down on the relevant groups/variables.

@denismaier
Copy link
Member

You are probably correct.

Another thing I'm thinking of: if we indeed do this, we could change container- and volume- variables to relationships. Because most variables are called by macros anyway, and your suggestion would make having related attributes everywhere obsolete.

@bwiernik
Copy link
Member Author

Let's leave that discussion for another day 😏

@denismaier
Copy link
Member

denismaier commented Aug 14, 2020

That would also make it clear what should happen when this appears:
<text macro="contributors" related="original"/>

The general inheritance rules are that a lower-level specification overrides an inherited value from higher-up. I think that's fine here. If that shouldn't happen, the style should be written accordingly.

Again: What should happen if you define a macro like so:

<macro name="reviewed" related="reviewed">
...
</macro>

And then you call it like that:

<text macro="reviewed" related="original"/>

I don't think that would make much sense.

There maybe should be two variants:

  1. macro definition without @related, macro call with @related
  2. macro definition with @related, macro call without @related

And, of course, definition and call without @related will also stay valid.

I fear allowing @related at the same time on definition and call could open the door to a lot of bugs and unexpected behavior.

Is that correct? If yes, is there a way to specify this? Probably not in rnc, but what about schematron? @bdarcus @bwiernik

@bdarcus
Copy link
Member

bdarcus commented Aug 14, 2020

If yes, is there a way to specify this? Probably not in rnc, but what about schematron?

I don't think you could do it in RNC.

Should be easy in schematron.

@denismaier
Copy link
Member

Should be easy in schematron.

Ok. At least.

And what do you think about the overall issue?

@bdarcus
Copy link
Member

bdarcus commented Aug 14, 2020

First thoughts (subject to change):

  • I don't see why we should allow @related on macro.
  • I don't think we should allow @related on macro calls; I agree it introduces potential problems, and I don't see the benefit weighed against those risks

What am I missing?

@denismaier
Copy link
Member

First thoughts (subject to change):

  • I don't see why we should allow @related on macro.
  • I don't think we should allow @related on macro calls; I agree it introduces potential problems, and I don't see the benefit weighed against those risks

What am I missing?

The idea is 1. to make macros usable with different relations (e.g. a macro "title" with reviewed and original relations), and 2. to make macro definitions easier (no need to repeat @related="original on each element in the macro definition).

@bdarcus
Copy link
Member

bdarcus commented Aug 14, 2020

The idea is 1. to make macros usable with different relations (e.g. a macro "title" with reviewed and original relations), and 2. to make macro definitions easier (no need to repeat @related="original on each element in the macro definition).

I meant only on the macro node; not on sub-elements within it.

Is the second worth the cost?

@denismaier
Copy link
Member

Sorry, I wasn't clear about the first use case.
That was supposed to mean this:

<macro name="title">
...
</macro>

Later you call it with:

text macro="title" related="reviewed"/> or text macro="title" related="original"/>

@denismaier
Copy link
Member

denismaier commented Aug 16, 2020

So @bdarcus @bwiernik what do you think? Should we add @related to macros and groups?
Other opinions, @georgd @cormacrelf @fbennett @PaulStanley @jgm?

@bwiernik
Copy link
Member Author

bwiernik commented Aug 16, 2020

I don't have a strong preference one way or the other on cs:macro. I would like to see it on cs:group. If we don't allow it on cs:macro, then we should write the schema to disallow:
<text macro="contributors" related="original"/>

@georgd
Copy link

georgd commented Aug 16, 2020

I think, @related is indispensable on cs:text[@variable]and on cs:group.

Allowing it on cs:text[@macro] calls might prove useful if that element is the only one of the related item to be called at that place, so using a group wouldn’t make much sense.

Allowing it on cs:macro is not so important IMO as you’d naturally use a cs:group inside it if calling multiple elements. If not, you could as well put the @related on the single element and still name the macro accordingly.

An other point that I haven’t seen in this discussion: what about nested relationships? Say, a macro contains a cs:group[@related="reviewed"] which in turn contains a cs:group[@related="original"] further down the tree. Which item is the @related="original" pointing to? I assume the original-relation of the reviewed item?

@bwiernik
Copy link
Member Author

Allowing it on cs:text[@macro] calls might prove useful if that element is the only one of the related item to be called at that place, so using a group wouldn’t make much sense.

I don't know what you mean here. If the macro only contains one element, then it can just be rendered as a single rendering element (but then why is it a macro anyway?).

An other point that I haven’t seen in this discussion: what about nested relationships?

My thinking was that there would be no nested relationships. We should probably explicitly disallow them in the data schema.

@bdarcus
Copy link
Member

bdarcus commented Aug 16, 2020

My thinking was that there would be no nested relationships. We should probably explicitly disallow them in the data schema.

I agree, but it's not possible or convenient to do this formally, in the JSON schema, at least.

Would need to be communicated via documentation.

@georgd
Copy link

georgd commented Aug 16, 2020

Allowing it on cs:text[@macro] calls might prove useful if that element is the only one of the related item to be called at that place, so using a group wouldn’t make much sense.

I don't know what you mean here. If the macro only contains one element, then it can just be rendered as a single rendering element (but then why is it a macro anyway?).

What I was thinking of: within a cs:group, you are calling various macros but only one of them is a related macro, all the others refer to the item itself:

<group delimiter=", ">
  <text macro="title"/>
  <text macro="issued"/>
  <text macro="title" related="original"/>
  <text macro="accessed"/>
</group>

@bdarcus
Copy link
Member

bdarcus commented Aug 16, 2020

This is why I think we probably shouldn't allow that.

The style author should write two macros, or a single macro with whatever conditional logic.

@georgd
Copy link

georgd commented Aug 16, 2020

This is why I think we probably shouldn't allow that.

The style author should write two macros, or a single macro with whatever conditional logic.

I’m sorry, I’m missing the reason for not allowing it.

@bdarcus
Copy link
Member

bdarcus commented Aug 16, 2020 via email

@georgd
Copy link

georgd commented Aug 16, 2020

Concern about complexity, debugging, etc..

I'm not 100% certain on this yet though, so could be convinced otherwise.

Is this about nested relations or about @related on cs:text[@macro]?

@bwiernik
Copy link
Member Author

I think we want to avoid any situation where a block is applied to two different "items" (e.g., the base item, original, reviewed). If that's possible, it's going to be highly prone to incorrect output.

@bwiernik
Copy link
Member Author

I see no reason to allow it on cs:macro---just put it on a ca:group inside if needed.

With respect to cs:text@macro, I agree that I see too many cases of ambiguous expectations, that I it would be best to prohibit inheritance of @related on it.

@georgd
Copy link

georgd commented Aug 17, 2020 via email

@bwiernik
Copy link
Member Author

bwiernik commented Aug 17, 2020

I think we should prohibit that.

@georgd
Copy link

georgd commented Aug 17, 2020

Sorry for my igrnorance: will xml-validators detect that in nested macro calls?

@bwiernik
Copy link
Member Author

Oh, you mean in styles, not in data. In styles, this would follow normal inheritance rules--a specified attribute overrides an inherited attribute.

@denismaier
Copy link
Member

Ok, coming back to this now. I think I can start a PR in the not so distant future. I propose we add @related on cs:date, cs:names, cs:number, and on cs:text when it renders a variable. cs:text with term or value won't make much sense anyway.

@denismaier denismaier self-assigned this Sep 3, 2020
@bwiernik
Copy link
Member Author

bwiernik commented Sep 3, 2020

That sounds good.

At least for CSL 1.1, we should keep the deprecated plain related variables around, with the understanding that <text variable="original-title" is equivalent to <text variable="title" related="original"/>.

@denismaier denismaier linked a pull request Sep 5, 2020 that will close this issue
4 tasks
@denismaier
Copy link
Member

On keeping these around, see my comment in the PR.

@bwiernik bwiernik linked a pull request Sep 7, 2020 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants