√ Strange behavior of cs:choose & disambiguate="true"
In a cs:choose, should cs:else execute when any one of the preceding cs:if and cs:else-if has already triggered? With the code below that I use to troubleshoot disambiguation, I always get "disambiguate value is false" and "disambiguate value neither true or false" together. Is this right? (If it is, it really shatters my understanding of cs:choose, and I'll have to re-write a few styles.)
<choose>
<if disambiguate="true">
<text value="disambiguate value is true"/>
</if>
<else-if dismbiguate="false">
<text value="disambiguate value is false"/>
</else-if>
<else>
<text value="disambiguate value neither true or false"/>
</else>
</choose>
Since disambiguate is a binary condition, the "else-if" makes no sense there and is in fact the same as a regular else. I assume that's why the processor is putting out both.
<choose>
<if disambiguate="false">
<text value="disambiguate value is false"/>
</if>
<else>
<text value="disambiguate value neither true or false"/>
</else>
</choose>
Still, I get both "disambiguate value is false" and "disambiguate value neither true or false" together for all subsequent citations. As I noted in another thread (https://forums.zotero.org/discussion/34475/how-is-the-disambiguate-boolean-determined), due to this errant behavior, I can't disambiguate.
Loo king at your code there, it won't actually diambiguate anything, since you are applying the same string to all entries. Try testing with real data.
Yes, I think my style is probably off. I applied a different style (than the one I wrote) which also incorporates disambiguate="true", and it works fine. Is there an option within CSL that may be hindering the proper operation of "disambiguate"?
Actually the snippet I posted above came from an actual macro:
<macro name="foreign-secondary-subsequent">
<group delimiter=", ">
<choose>
<if type="book">
<text macro="foreign-author-short" />
</if>
<else-if type="webpage" variable="issued" match="all">
<text macro="foreign-author-short" />
</else-if>
<else>
<text macro="foreign-author-short"/>
</else>
</choose>
<choose>
<if disambiguate="true">
<text macro="foreign-short-title" text-case="title"/>
</if>
** rest is deleted **
The disambiguate="true" in the code above doesn't work.
The funny thing is that when that macro is called upon within the MLZ Amlaw style, it will disambiguate fine. But when it's called upon in my style, it won't. Below is a snippet of the cs macro name="amlaw-title" that I modified to get a cue about what is triggered and what is not. The same disambiguate="true" is triggered when this macro is called upon in MLZ Amlaw, but not when it's called upon in my style.
I'm totally at a loss.
<else-if>
<conditions match="any">
<condition type="song" variable="collection-title" match="all"/>
<condition type="broadcast" variable="container-title" match="all"/>
<condition type="video" variable="container-title" match="all"/>
<condition type="post" variable="container-title" match="all"/>
<condition type="post-weblog" variable="container-title" match="all"/>
<condition type="webpage" variable="container-title" match="all"/>
<condition type="paper-conference" variable="container-title" match="all"/>
<condition type="article-magazine graphic article-journal article-newspaper chapter" match="any"/>
<condition type="entry-encyclopedia"/>
<condition type="entry-dictionary"/>
</conditions>
<text value="choice #9"/>
<choose>
<if>
<conditions match="any">
<condition position="first" context="bibliography" match="any"/>
<condition variable="author container-author" match="none"/>
</conditions>
<text font-style="italic" form="short" text-case="title" variable="title"/>
</if>
</choose>
<choose>
<if disambiguate="true">
<text value="disambiguation triggered "/>
<text font-style="italic" form="short" text-case="title" variable="title"/>
</if>
</choose>
</else-if>
The most glaring errors were an apostrophe character between two XML nodes, and a use of punctuation-in-quote on a cs:name node. Both of those are pretty serious, and could well adversely affect the operation of the processor. The various syntax errors are almost certainly the cause of the disambiguation failures you are seeing.
There is a lot of new code in there -- the style is over 4,000 lines long, over a thousand lines longer than the largest MLZ styles. The size itself isn't a problem for the processor, but the more code there is, the harder it becomes to maintain the style. You might want to take a careful look and see whether there isn't potential for consolidating portions of the code to make it more compact.
Note that the code I've posted above still doesn't validate. The code in the style makes extensive use of illegal space characters on affixes. Removing them will take some effort, but they'll need to be removed for the style to fully validate against the CSL-m schema. Trailing spaces on suffixes and leading spaces on prefixes are not permitted in CSL-m syntax outside of cs:date and cs:name nodes: ordinary spaces can only be supplied through a group delimiter. I've imposed that constraint on the syntax because elements with hard-coded spaces can easily produce broken formatting when variables are missing from the input.
The disambiguate="true" conditionals may work correctly in the code I've posted above, but it would be a really good idea to go through the code to weed out the affixes and simplify the macros where possible.
I'm surprised that your CSL-m validator found errors in my style, as I didn't run into any when I validated it on my computer with the same validator. My style ran fine in chrome://zotero/content/tools/csledit.xul too (albeit without the desired outcome). I'll take another look.
In any event, I had no idea spaces are not allowed in suffixes and prefixes. If that's the case, yes, there is a bit of cleaning up to do.
Thanks, and have a wonderful weekend!
Did the code you posted above work correctly for you? It still doesn't disambiguate in mine. Is there a chance that it's because I'm using the special MLZ that you provided to deal with the other issue from last week?
:-)
I've started building one, but on the initial run, I get this:
CSL style error: undefined macro "ko-title"
<else-if>
<conditions match="all">
<condition position="subsequent"/>
<condition position="ibid" match="none"/>
</conditions>
<text macro="ko-secondary-subsequent"/>
</else-if>
<else-if type="book" >
<text macro="ko-book"/>
</else-if>
<else-if type="chapter">
<text macro="ko-chapter"/>
</else-if>
<else-if type="article-journal">
<text macro="ko-periodical"/>
</else-if>
(The disambiguation is done within macro="ko-secondary-subsequent".)
Previously, the ibid/ibid-with-locator/subsequent tri-furcation was built into each of ko-book, ko-chapter and ko-periodican, and macro="ko-secondary-subsequent" would be called upon by each if the citation was a subsequent one.
In this version, as you can see, I check position="subsequent" first. I have no idea why this routine disambiguates, whereas the previous one didn't.