Patch II

Karsten Ohme <[email protected]> Mon, 30 May 2005 02:24:14 +0200
Newsgroups gmane.text.docbook.db2latex.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------080209020309090201040309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

I corrected something else from the last mail. The patch includes now 
the following:

Toto be able to work, I had to include one patch in the 
qandaset.mod.xsl, which removes a template which is not used and let 
every XSLT processor fail. This patch was already there, but not 
included in the CVS. Why?

Another bug was a missing '' in preamble.mod.xsl in line 523 for saxon 8

-        <xsl:if test="$latex.use.varioref='1'">
+        <xsl:if test="$latex.use.varioref=1">

I added a support for the scale and align="center" attribute of graphic 
of DocBook. Additional the scale attribute is honored and creates a 
\scalebox. If the width and the height are specified, a bb= attibut is 
appended to the \includegraphics command. this is important for 
rendering png images with latex.

Default now text is not justified, it is ragged right. A paramter for 
this would be a better solution.

I added an attribut latex.customcommand. You can define in your custom 
stylesheet custom Latex commands. E.g. the following defines a abstract 
environment for the book class.

     <xsl:param name="latex.customcommand">
         <xsl:text><![CDATA[
   \makeatletter
   \renewenvironment{abstract}{%
       \if@twocolumn
         \section*{\abstractname}%
       \else
         \small
         \begin{center}%
           {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
         \end{center}%
         \quotation
       \fi}
       {\if@twocolumn\else\endquotation\fi}
   \makeatother
]]>
		</xsl:text>

Please include this.

Bye, Karsten

--------------080209020309090201040309
Content-Type: text/plain;
 name="db2latex.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="db2latex.diff"

diff -ubNr db2latex/xsl/book-article.mod.xsl db2latex-xsl-my/xsl/book-article.mod.xsl
--- db2latex/xsl/book-article.mod.xsl	2004-08-12 08:18:58.000000000 +0200
+++ db2latex-xsl-my/xsl/book-article.mod.xsl	2005-05-27 22:09:08.056068800 +0200
@@ -63,6 +63,7 @@
 				<listitem><simpara><xref linkend="param.latex.book.begindocument"/></simpara></listitem>
 				<listitem><simpara><xref linkend="param.latex.titlepage.file"/></simpara></listitem>
 				<listitem><simpara><xref linkend="param.latex.maketitle"/></simpara></listitem>
+				<listitem><simpara><xref linkend="param.latex.tableofcontents"/></simpara></listitem>
 			</itemizedlist>
 		</doc:variables>
 		<!--
@@ -118,9 +119,11 @@
 			<xsl:text>}}</xsl:text>
 		</xsl:if>
 		<!-- book:7b: maketitle and set up pagestyle -->
+		<xsl:value-of select="$latex.customcommand"/>
 		<xsl:value-of select="$latex.maketitle"/>
 		<!-- book:8: - APPLY TEMPLATES -->
 		<xsl:apply-templates select="bookinfo"/>
+		<xsl:value-of select="$latex.tableofcontents"/>
 		<xsl:call-template name="content-templates-rootid"/>
 		<!-- book:9:  call map.end -->
 		<xsl:call-template name="map.end"/>
@@ -478,6 +481,7 @@
 		<xsl:call-template name="map.begin"/>
 		<xsl:value-of select="$latex.maketitle"/>
 		<xsl:apply-templates select="artheader|articleinfo" mode="standalone.article"/>
+		<xsl:value-of select="$latex.tableofcontents"/>
 		<xsl:call-template name="content-templates-rootid"/>
 		<xsl:call-template name="map.end"/>
     </xsl:template>
diff -ubNr db2latex/xsl/graphic.mod.xsl db2latex-xsl-my/xsl/graphic.mod.xsl
--- db2latex/xsl/graphic.mod.xsl	2004-01-02 08:25:45.000000000 +0100
+++ db2latex-xsl-my/xsl/graphic.mod.xsl	2005-05-27 18:30:34.349484800 +0200
@@ -102,7 +102,24 @@
 		</doc:variables>
 	</doc:template>
 	<xsl:template match="inlinegraphic" name="inlinegraphic">
-		<xsl:text>\includegraphics{</xsl:text>
+		<xsl:text>\vspace{2ex}</xsl:text>
+		<xsl:if test="@align=center">
+            <xsl:text>\begin{center}</xsl:text>
+        </xsl:if>
+		<xsl:if test="@scale">
+			<xsl:text>\scalebox{0.</xsl:text>
+			<xsl:value-of select="@scale"/>
+            <xsl:text>}{</xsl:text>
+        </xsl:if>
+        <xsl:text>\includegraphics</xsl:text>
+       	<xsl:if test="@width and @height">
+       		<xsl:text>[bb= 0 0 </xsl:text>
+       		<xsl:value-of select="@width"/>
+       		<xsl:text> </xsl:text>
+       		<xsl:value-of select="@height"/>
+       		<xsl:text>]</xsl:text>
+       	</xsl:if>
+        <xsl:text>{</xsl:text>
 		<xsl:choose>
 			<xsl:when test="@entityref">
 				<xsl:value-of select="unparsed-entity-uri(@entityref)"/>
@@ -112,6 +129,13 @@
 			</xsl:otherwise>
 		</xsl:choose>
 		<xsl:text>}</xsl:text>
+		<xsl:if test="@scale">
+			<xsl:text>}</xsl:text>
+        </xsl:if>
+		<xsl:if test="@align=center">
+            <xsl:text>\end{center}</xsl:text>
+        </xsl:if>
+		<xsl:text>\vspace{2ex}</xsl:text>
 	</xsl:template>
 
 </xsl:stylesheet>
diff -ubNr db2latex/xsl/param-direct.mod.xsl db2latex-xsl-my/xsl/param-direct.mod.xsl
--- db2latex/xsl/param-direct.mod.xsl	2004-08-12 07:17:01.000000000 +0200
+++ db2latex-xsl-my/xsl/param-direct.mod.xsl	2005-05-27 22:26:53.818560000 +0200
@@ -66,6 +66,18 @@
 		<xsl:text>{\maketitle</xsl:text>
 		<xsl:call-template name="generate.latex.pagestyle"/>
 		<xsl:text>\thispagestyle{empty}}&#10;</xsl:text>
+		<xsl:text>\raggedright&#10;</xsl:text>
+	</xsl:param>
+
+
+	<doc:param xmlns="">
+		<refpurpose> The <literal>\rableofcontents</literal> for books and articles. </refpurpose>
+		<doc:description>
+			<para>Some users may wish to override or eliminate <literal>\tableofcontents</literal>.</para>
+		</doc:description>
+	</doc:param>
+	<xsl:param name="latex.tableofcontents">
+		<xsl:text>\tableofcontents</xsl:text>
 	</xsl:param>
 
 	<doc:param xmlns="">
diff -ubNr db2latex/xsl/preamble.mod.xsl db2latex-xsl-my/xsl/preamble.mod.xsl
--- db2latex/xsl/preamble.mod.xsl	2004-01-31 13:26:12.000000000 +0100
+++ db2latex-xsl-my/xsl/preamble.mod.xsl	2005-05-27 21:40:35.203107200 +0200
@@ -523,7 +523,7 @@
 		<xsl:text>% ---------------------- &#10;</xsl:text>
 		<xsl:text>% Most Common Packages   &#10;</xsl:text>
 		<xsl:text>% ---------------------- &#10;</xsl:text>
-		<xsl:if test="$latex.use.varioref=1">
+		<xsl:if test="$latex.use.varioref='1'">
 			<xsl:text>\usepackage[</xsl:text>
 			<xsl:value-of select="$latex.varioref.options"/>
 			<xsl:text>]{varioref} &#10;</xsl:text>
diff -ubNr db2latex/xsl/qandaset.mod.xsl db2latex-xsl-my/xsl/qandaset.mod.xsl
--- db2latex/xsl/qandaset.mod.xsl	2004-01-04 14:22:27.000000000 +0100
+++ db2latex-xsl-my/xsl/qandaset.mod.xsl	2005-05-27 14:03:02.988761600 +0200
@@ -363,53 +363,4 @@
 	</doc:template>
 	<xsl:template match="revhistory" mode="qandatoc.mode"/>
 
-<xsl:template name="question.answer.label">
-	<!-- variable: deflabel -->
-  <xsl:variable name="deflabel">
-  	<!-- chck whether someone has a defaultlabel attribute -->
-    <xsl:choose>
-		<xsl:when test="ancestor-or-self::*[@defaultlabel]">
-        	<xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]/@defaultlabel"/>
-	      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="latex.qanda.defaultlabel"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-
-  <xsl:variable name="label" select="@label"/>
-  <xsl:choose>
-    <xsl:when test="$deflabel = 'qanda'">
-      <xsl:call-template name="gentext">
-        <xsl:with-param name="key">
-          <xsl:choose>
-            <xsl:when test="local-name(.) = 'question'">question</xsl:when>
-            <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
-            <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
-            <xsl:otherwise>qandaset</xsl:otherwise>
-          </xsl:choose>
-        </xsl:with-param>
-      </xsl:call-template>
-    </xsl:when>
-    <xsl:when test="$deflabel = 'label'">
-      <xsl:value-of select="$label"/>
-    </xsl:when>
-    <xsl:when test="$deflabel = 'number' and local-name(.) = 'question'">
-      <xsl:apply-templates select="ancestor::qandaset[1]" mode="number"/>
-      <xsl:choose>
-        <xsl:when test="ancestor::qandadiv">
-          <xsl:apply-templates select="ancestor::qandadiv[1]" mode="number"/>
-          <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:apply-templates select="ancestor::qandaentry" mode="number"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:when>
-    <xsl:otherwise>
-      <!-- nothing -->
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
 </xsl:stylesheet>
diff -ubNr db2latex/xsl/xref.mod.xsl db2latex-xsl-my/xsl/xref.mod.xsl
--- db2latex/xsl/xref.mod.xsl	2004-08-12 08:23:33.000000000 +0200
+++ db2latex-xsl-my/xsl/xref.mod.xsl	2005-05-30 02:01:48.692950400 +0200
@@ -750,7 +750,6 @@
 <xsl:template match="*" mode="xref-to">
   <xsl:param name="referrer"/>
   <xsl:param name="xrefstyle"/>
-
   <xsl:message>
     <xsl:text>Don't know what gentext to create for xref to: "</xsl:text>
     <xsl:value-of select="name(.)"/>

--------------080209020309090201040309--


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005