1;; Id: patch-db2latex-duplicate-template-bug,v 1.2 2007/01/12 22:24:20 sra Exp
2;;
3;; This is a patch to work around a known bug in db2latex.  Apparently
4;; xsltproc's error checking got a lot better since the authors of
5;; db2latex last tested this, so a clear language violation that
6;; xsltproc used to ignore now prevents xsltproc from working with
7;; db2latex.
8;;
9;; On FreeBSD you can simply drop this patch into the directory
10;; /usr/ports/textproc/db2latex/files/ and the ports system should
11;; take it from there.  I've sent this patch off to the port
12;; maintainer but have not yet heard anything back.
13;;
14;; I don't really know whther this is the "right" fix, but it seems to
15;; work, and I'm pretty sure that the code this patch deletes does not
16;; work as it stands, so at worst the result after applying this patch
17;; should be no worse than the result without this patch.
18;;
19;; YMMV.  If this patch breaks, you get to keep both pieces.
20
21Index: xsl/qandaset.mod.xsl
22--- xsl/qandaset.mod.xsl.~1~	Sun Jan  4 08:22:27 2004
23+++ xsl/qandaset.mod.xsl	Fri Apr  1 22:30:20 2005
24@@ -363,53 +363,4 @@
25 	</doc:template>
26 	<xsl:template match="revhistory" mode="qandatoc.mode"/>
27
28-<xsl:template name="question.answer.label">
29-	<!-- variable: deflabel -->
30-  <xsl:variable name="deflabel">
31-  	<!-- chck whether someone has a defaultlabel attribute -->
32-    <xsl:choose>
33-		<xsl:when test="ancestor-or-self::*[@defaultlabel]">
34-        	<xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
35-	      </xsl:when>
36-      <xsl:otherwise>
37-        <xsl:value-of select="latex.qanda.defaultlabel"/>
38-      </xsl:otherwise>
39-    </xsl:choose>
40-  </xsl:variable>
41-
42-  <xsl:variable name="label" select="@label"/>
43-  <xsl:choose>
44-    <xsl:when test="$deflabel = 'qanda'">
45-      <xsl:call-template name="gentext">
46-        <xsl:with-param name="key">
47-          <xsl:choose>
48-            <xsl:when test="local-name(.) = 'question'">question</xsl:when>
49-            <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
50-            <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
51-            <xsl:otherwise>qandaset</xsl:otherwise>
52-          </xsl:choose>
53-        </xsl:with-param>
54-      </xsl:call-template>
55-    </xsl:when>
56-    <xsl:when test="$deflabel = 'label'">
57-      <xsl:value-of select="$label"/>
58-    </xsl:when>
59-    <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
60-      <xsl:apply-templates select="ancestor::qandaset[1]" mode="number"/>
61-      <xsl:choose>
62-        <xsl:when test="ancestor::qandadiv">
63-          <xsl:apply-templates select="ancestor::qandadiv[1]" mode="number"/>
64-          <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
65-        </xsl:when>
66-        <xsl:otherwise>
67-          <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
68-        </xsl:otherwise>
69-      </xsl:choose>
70-    </xsl:when>
71-    <xsl:otherwise>
72-      <!-- nothing -->
73-    </xsl:otherwise>
74-  </xsl:choose>
75-</xsl:template>
76-
77 </xsl:stylesheet>
78