OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Rework of gentext.template in 1.76.0 broke custom contexts


Hi all,
 
I am currently upgrading from 1.75.2 to latest release, 1.78.0, and the 
gentext.template template broke for me. The reason is, I use custom context to 
provide localization for some non-standard context, for example "Run-in text 
for admonitions" as follows:
 
<xsl:param name="local.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
 <l:l10n language="en">
  ...
  <l:context name="admon-run-in">
   <l:template name="note" text="Note:&#160;"/>
   <l:template name="caution" text="Caution!&#160;"/>
   ...
  </l:context>
 </l:l10n>
</l:i18n>
 
This context is used in customization templates:
 
<xsl:call-template name="gentext.template">
<xsl:with-param name="context">admon-run-in</xsl:with-param>
<xsl:with-param name="name" select="local-name(.)"/>
</xsl:call-template>
 
 
This works fine with 1.75.2. However, starting with 1.76.0, the 
gentext.template template was modified as follows:
 
<xsl:variable name="local.template.node" .../>
<xsl:for-each select="$context.node">
...
<xsl:choose>
<xsl:when test="$local.template.node/@text">
<xsl:value-of select="$local.template.node/@text"/>
</xsl:when>
 
This change broke such "custom" contexts for l10n, as in such custom context 
$context.node is an empty nodeset (that is, there is no "default" string for 
this template). Therefore, the xsl:for-each loop is not executed at all and 
the local value is not returned by template even though it is defined.
 
The attached patch restores pre-1.76.0 behavior: first check if text from 
$local.template.node is available and perform xsl:for-each only if no local 
template is available.
 
Got the following response on docbook@ from Jirka Kosek:
 
> Please submit bug and patch using tracker at the SourceForge:
> http://sourceforge.net/tracker/?group_id=21935&atid=373747
>
> I don't see reason why this should not be integrated however I don't
> think this is a bug, localization code was designed to offer overrides
> for built-in translations, see:
>
> https://lists.oasis-open.org/archives/docbook-apps/201207/msg00013.html
 
Submitted a bug, patch attached:
https://sourceforge.net/tracker/?func=detail&aid=3598963&group_id=21935&atid=373747

As to whether it is a bug, I beg to disagree: DocBook stylesheets are designed 
to allow a customization layer. If that customization layer has a template 
which requires some language-dependent text, such as the example in my 
original email - or in the other email you refered to - gentext.template is 
the natural choice.
The other options are:
- two different kinds of templates to select language-dependent text, one for 
"built-in" templates and one for "add-on" ones, which just adds unnecessary 
duplication of XSL code
- piggybacking such local context onto some existing context, which is, I 
quote from the message referenced above, "Not nice, but will work".
 
Could this patch be integrated?
 
Thanks,
Alexey.
Index: docbook-xsl-1.78.0/common/l10n.xsl
===================================================================
--- docbook-xsl-1.78.0/common/l10n.xsl	(working copy)
+++ docbook-xsl-1.78.0/common/l10n.xsl	(working copy)
@@ -507,51 +507,54 @@
 								and @style=$xrefstyle]
 				|$local.context.node/l:template[@name=$name
 								and not(@style)])[1]"/>
+	  <xsl:choose>
+	    <xsl:when test="$local.template.node/@text">
+	      <xsl:value-of select="$local.template.node/@text"/>
+	    </xsl:when>
+	    <xsl:otherwise>
+	      <xsl:for-each select="$context.node">
+		<xsl:variable name="template.node"
+			      select="(key('l10n-template-style', concat($context, '#', $name, '#', $xrefstyle))
+				       |key('l10n-template', concat($context, '#', $name)))[1]"/>
 
-	  <xsl:for-each select="$context.node">
-	    <xsl:variable name="template.node"
-			  select="(key('l10n-template-style', concat($context, '#', $name, '#', $xrefstyle))
-				   |key('l10n-template', concat($context, '#', $name)))[1]"/>
-
-	    <xsl:choose>
-	      <xsl:when test="$local.template.node/@text">
-		<xsl:value-of select="$local.template.node/@text"/>
-	      </xsl:when>
-	      <xsl:when test="$template.node/@text">
-		<xsl:value-of select="$template.node/@text"/>
-	      </xsl:when>
-	      <xsl:otherwise>
 		<xsl:choose>
-		  <xsl:when test="contains($name, '/')">
-		    <xsl:call-template name="gentext.template">
-		      <xsl:with-param name="context" select="$context"/>
-		      <xsl:with-param name="name" select="substring-after($name, '/')"/>
-		      <xsl:with-param name="origname" select="$origname"/>
-		      <xsl:with-param name="purpose" select="$purpose"/>
-		      <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
-		      <xsl:with-param name="referrer" select="$referrer"/>
-		      <xsl:with-param name="lang" select="$lang"/>
-		      <xsl:with-param name="verbose" select="$verbose"/>
-		    </xsl:call-template>
+		  <xsl:when test="$template.node/@text">
+		    <xsl:value-of select="$template.node/@text"/>
 		  </xsl:when>
-		  <xsl:when test="$verbose = 0">
-		    <!-- silence -->
-		  </xsl:when>
 		  <xsl:otherwise>
-		    <xsl:message>
-		      <xsl:text>No template for "</xsl:text>
-		      <xsl:value-of select="$origname"/>
-		      <xsl:text>" (or any of its leaves) exists in the context named "</xsl:text>
-		      <xsl:value-of select="$context"/>
-		      <xsl:text>" in the "</xsl:text>
-		      <xsl:value-of select="$lang"/>
-		      <xsl:text>" localization.</xsl:text>
-		    </xsl:message>
+		    <xsl:choose>
+		      <xsl:when test="contains($name, '/')">
+			<xsl:call-template name="gentext.template">
+			  <xsl:with-param name="context" select="$context"/>
+			  <xsl:with-param name="name" select="substring-after($name, '/')"/>
+			  <xsl:with-param name="origname" select="$origname"/>
+			  <xsl:with-param name="purpose" select="$purpose"/>
+			  <xsl:with-param name="xrefstyle" select="$xrefstyle"/>
+			  <xsl:with-param name="referrer" select="$referrer"/>
+			  <xsl:with-param name="lang" select="$lang"/>
+			  <xsl:with-param name="verbose" select="$verbose"/>
+			</xsl:call-template>
+		      </xsl:when>
+		      <xsl:when test="$verbose = 0">
+			<!-- silence -->
+		      </xsl:when>
+		      <xsl:otherwise>
+			<xsl:message>
+			  <xsl:text>No template for "</xsl:text>
+			  <xsl:value-of select="$origname"/>
+			  <xsl:text>" (or any of its leaves) exists in the context named "</xsl:text>
+			  <xsl:value-of select="$context"/>
+			  <xsl:text>" in the "</xsl:text>
+			  <xsl:value-of select="$lang"/>
+			  <xsl:text>" localization.</xsl:text>
+			</xsl:message>
+		      </xsl:otherwise>
+		    </xsl:choose>
 		  </xsl:otherwise>
 		</xsl:choose>
-	      </xsl:otherwise>
-	    </xsl:choose>
-	  </xsl:for-each>
+	      </xsl:for-each>
+	    </xsl:otherwise>
+	  </xsl:choose>
 	</xsl:for-each>
       </xsl:for-each>
     </xsl:otherwise>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]