Patch III - I hope the last

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

Hello,

I'm finished. Unfortunately again a patch of my own patch. I hate it.

What's left:

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

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 scalefit and align="center" attribute of 
graphic of DocBook. The scalefit attribute crates a resizebox which 
makes the graphic to the size of the column (\columnwidth). maybe this 
should overwritten, in a costum style sheet.
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.
The scalefit and the width attribut is abused, actuallay the semantic of 
this paramters is different, but it works mostly in a way a user would 
expect. The height parameter does not exist in DocBook and the 
validation should fail ... There should be a better solution.

Default now text is not justified, it is ragged right. A parameter for 
this would be a better solution. Does one exist?

I added an attribut latex.customcommand. You can redefine in your custom 
stylesheet custom Latex commands. E.g. the following defines a abstract 
environment for the report class. (I had the problem, that the 
pagenumbers or wrong else (Why? Don't know.)).

     <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>

Bye, Karsten

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

diff -rNubB db2latex/xsl/book-article.mod.xsl db2latex-xsl-0.8pre1/xsl/book-article.mod.xsl
--- db2latex/xsl/book-article.mod.xsl	2004-08-12 08:18:58.000000000 +0200
+++ db2latex-xsl-0.8pre1/xsl/book-article.mod.xsl	2005-05-30 19:53:59.648964800 +0200
@@ -118,6 +118,7 @@
 			<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"/>
diff -rNubB db2latex/xsl/graphic.mod.xsl db2latex-xsl-0.8pre1/xsl/graphic.mod.xsl
--- db2latex/xsl/graphic.mod.xsl	2004-01-02 08:25:45.000000000 +0100
+++ db2latex-xsl-0.8pre1/xsl/graphic.mod.xsl	2005-05-30 14:55:43.725891200 +0200
@@ -102,7 +102,28 @@
 		</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="@scalefit=1">
+			<xsl:text>\resizebox{\columnwidth}{!}{</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 +133,17 @@
 			</xsl:otherwise>
 		</xsl:choose>
 		<xsl:text>}</xsl:text>
+		<xsl:if test="@scalefit=1">
+			<xsl:text>}</xsl:text>
+        </xsl:if>
+<!--		<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 -rNubB db2latex/xsl/param-direct.mod.xsl db2latex-xsl-0.8pre1/xsl/param-direct.mod.xsl
--- db2latex/xsl/param-direct.mod.xsl	2004-08-12 07:17:01.000000000 +0200
+++ db2latex-xsl-0.8pre1/xsl/param-direct.mod.xsl	2005-05-30 19:54:19.407376000 +0200
@@ -66,6 +66,7 @@
 		<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="">
diff -rNubB db2latex/xsl/preamble.mod.xsl db2latex-xsl-0.8pre1/xsl/preamble.mod.xsl
--- db2latex/xsl/preamble.mod.xsl	2004-01-31 13:26:12.000000000 +0100
+++ db2latex-xsl-0.8pre1/xsl/preamble.mod.xsl	2005-05-30 14:28:29.315724800 +0200
@@ -248,6 +248,19 @@
 	</xsl:param>
 
 	<doc:param xmlns="">
+		<refpurpose> Enables the user the redefine LaTeX commands, environments, ...  </refpurpose>
+		<doc:description>
+			<para>
+				If a user wants to redefine LaTeX commands, environments, ..., he can use this param.
+			</para>
+		</doc:description>
+		<doc:variables>
+			&no_var;
+		</doc:variables>
+	</doc:param>
+	<xsl:param name="latex.customcommand"/>
+	
+	<doc:param xmlns="">
 		<refpurpose> Select <productname>babel</productname> option </refpurpose>
 		<doc:description>
 			<para>
@@ -523,7 +536,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 -rNubB db2latex/xsl/qandaset.mod.xsl db2latex-xsl-0.8pre1/xsl/qandaset.mod.xsl
--- db2latex/xsl/qandaset.mod.xsl	2004-01-04 14:22:27.000000000 +0100
+++ db2latex-xsl-0.8pre1/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>

--------------080502020201080900050408--


-------------------------------------------------------
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