style development: 'else' equivalent for groups?
I am hacking a style to build a 'standard' for my university. For various reasons, it would be very useful to have the equivalent of an 'else' clause on a group. What I want to accomplish is that if a group (in all its complexity) produces no output, then some other 'statement' (in my case a macro) is executed, otherwise not.
I have currently solved the problem by putting all the variables that play in the first group into an 'if', executing the 'else' if all the variables are empty. This isn't ideal, but it works for the moment.
Something like <if is-empty="some-macro">, which tests the result of the macro in the obvious way, would work for me. So would <group alternative="some-macro">. More complicated, but perhaps more efficient and more powerful, would be
<assign somevar="some-macro>
<if variable="somevar">
where assign would create the variable only if it is non-empty.
BTW: thanks to Elena for the change in the dev version making conference paper map to paper-conference instead of chapter, and the associated change to presentation. The change solved a big problem for me, because our in-house version of Harvard requires the two to use different positioning and formatting for location and date.
I have currently solved the problem by putting all the variables that play in the first group into an 'if', executing the 'else' if all the variables are empty. This isn't ideal, but it works for the moment.
Something like <if is-empty="some-macro">, which tests the result of the macro in the obvious way, would work for me. So would <group alternative="some-macro">. More complicated, but perhaps more efficient and more powerful, would be
<assign somevar="some-macro>
<if variable="somevar">
where assign would create the variable only if it is non-empty.
BTW: thanks to Elena for the change in the dev version making conference paper map to paper-conference instead of chapter, and the associated change to presentation. The change solved a big problem for me, because our in-house version of Harvard requires the two to use different positioning and formatting for location and date.
In general, I try to adopt the "keep it as simple as possible" approach (not always easy of course given all the funky rules in many styles).
Also, it might make sense to post your style somewhere. There might be better ways to get what you're after.
..<macro name="year-date">
....<choose>
....<if variable="issued">
......<date variable="issued">
........<date-part name="year"/>
......</date>
....</if>
....<else>
......<text term="no date"/>
....</else>
....</choose>
..</macro>
to the following, which is easier to read and follow, but of course doesn't work.
..<macro name="no-date">
....<text term="no date"/>
..</macro>
..<macro name="year-date">
....<group alternative="no-date">
......<date variable="issued">
........date-part name="year"/>
......</date>
....</group>
..</macro>
You are correct about the funky rules. In my case, my university may refuse to adopt a tool if it doesn't produce 'correct' output. "Your tool is doesn't follow the rules. It is simpler to do it completely by hand than it is to fix its output." is a common refrain.
As for posting, I will, once I am convinced that what I have done works. For example, I am having problems with anonymous works. The example in the Harvard 1 dev style where an "anon" macro is used in a <substitute> block doesn't produce any output (using version 1.0.3r2467), and I need to play more to see if I have done something silly.