I have created a “fix” to this, but it is more complex than I expected. 

gentext.template.exists, as currently written, simply calls gentext.template 
and if the return value is null (‘’), it returns 0, otherwise it returns 1.

However, because gentext.template has to consider locale, context, and locally 
defined templates, there are multiple checks required to determine if a 
matching template actually exists.

Rather than duplicate that, I hijacked the $purpose parameter on 
gentext.template (that parameter is not used as far as I can tell), and when 
that parameter is set to ‘check’ it returns 1 anywhere that it finds and would 
have returned a value and returns 0 it it can’t find a template. If $purpose is 
anything else, gentext.template works the same as always.

gentext.template.exists stays pretty much the same, except that it sets purpose 
to ‘check’ when it calls gentext.template and returns whatever gentext.template 
returns. I take just the first character of the returned string. Because there 
are some loops that I suppose might hit a not-found value more than once, I 
thought that would be the safest course.

If that seems like the best, or at least a reasonable, way to fix this bug, I 
can make the changes and put in a pull request.

Dick 
-------
XML Press
XML for Technical Communicators
http://xmlpress.net
hamil...@xmlpress.net



> On Aug 26, 2020, at 15:08, Richard Hamilton <hamil...@xmlpress.net> wrote:
> 
> Hi Bob,
> 
> Thanks. I just filed this as an issue in github. 
> 
> I’ll take a look and see if I can find a fix.
> 
> Dick
> -------
> XML Press
> XML for Technical Communicators
> http://xmlpress.net
> hamil...@xmlpress.net
> 
> 
> 
>> On Aug 14, 2020, at 00:18, Bob Stayton <b...@sagehill.net> wrote:
>> 
>> I'm inclined to think that is a bug, because there are perhaps legitimate 
>> reasons for the text attribute of a particular gentext template to be empty 
>> in some languages.
>> Bob Stayton
>> 
>> b...@sagehill.net
>> On 8/11/2020 6:06 PM, Richard Hamilton wrote:
>>> The template gentext.template.exists in the 1.0 stylesheets has what may be 
>>> a bug.
>>> 
>>> This template says that it returns 1 if a gentext template exists for a 
>>> particular context and name and 0 if the template doesn’t exist.
>>> 
>>> However, if a gentext template does exist, but it has a text value that is 
>>> empty (e.g., <l:template name=“somename” text=“”/>), 
>>> gentext.template.exists returns 0, not 1.
>>> 
>>> That is, it doesn’t distinguish between a template with a null value for 
>>> the text and a non-existent template.
>>> 
>>> My question is whether this is a bug or a feature? I’m inclined to think 
>>> it’s a bug, but I’m not sure.
>>> 
>>> If it’s a bug, I’m glad to file a report.
>>> 
>>> Best regards,
>>> Dick Hamilton
>>> -------
>>> XML Press
>>> XML for Technical Communicators
>>> 
>>> http://xmlpress.net
>>> hamil...@xmlpress.net
>>> 
>>> 
>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: 
>>> docbook-apps-unsubscr...@lists.oasis-open.org
>>> 
>>> For additional commands, e-mail: 
>>> docbook-apps-h...@lists.oasis-open.org
>>> 
>>> 
>>> 
>>> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org

Reply via email to