[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] variablelist styles
Hi Laurie, Ok, for html output the following customization layer will do what you want. The parameter variablelist.as.runinhead is set to 1 (and variablelist.as.table must also be 0 or it will win) OR you can use the <?dbhtml list-presentation="runinhead"?> for individual variablelists. One thing to note: this works fine for the normal case where you have a varlistentry/lisitem/para (where para is the first child of the listitem), but what if they do varlistentry/listitem/*[1], where the first child of the listitem is not a para? That could end up looking funny. Currently, I only do the runinhead thing if the first child is a para. Otherwise, the normal formatting of the elment happens. You'll probably want to adapt it to real life, but this should get you started. Of course, you'll probably also want to do the same thing for the fo xsls :-) This only overrides one template from the base xsls (the one for variablelist). The other templates are new additions. Good luck, David <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xs l"/> <xsl:param name="variablelist.as.table">0</xsl:param> <xsl:param name="variablelist.as.runinhead">1</xsl:param> <!-- DWC: Modified to support runinhead style --> <xsl:template match="variablelist"> <xsl:variable name="pi-presentation"> <xsl:call-template name="dbhtml-attribute"> <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/> <xsl:with-param name="attribute" select="'list-presentation'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="presentation"> <xsl:choose> <xsl:when test="$pi-presentation != ''"> <xsl:value-of select="$pi-presentation"/> </xsl:when> <xsl:when test="$variablelist.as.table != 0"> <xsl:value-of select="'table'"/> </xsl:when> <xsl:when test="$variablelist.as.runinhead != 0"> <xsl:value-of select="'runinhead'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="'list'"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="list-width"> <xsl:call-template name="dbhtml-attribute"> <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/> <xsl:with-param name="attribute" select="'list-width'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="term-width"> <xsl:call-template name="dbhtml-attribute"> <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/> <xsl:with-param name="attribute" select="'term-width'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="table-summary"> <xsl:call-template name="dbhtml-attribute"> <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/> <xsl:with-param name="attribute" select="'table-summary'"/> </xsl:call-template> </xsl:variable> <div> <xsl:apply-templates select="." mode="class.attribute"/> <xsl:call-template name="anchor"/> <xsl:if test="title"> <xsl:call-template name="formal.object.heading"/> </xsl:if> <xsl:choose> <xsl:when test="$presentation = 'table'"> <!-- Preserve order of PIs and comments --> <xsl:apply-templates select="*[not(self::varlistentry or self::title or self::titleabbrev)] |comment()[not(preceding-sibling::varlistentry)] |processing-instruction()[not(preceding-sibling::varlistentry)]"/> <table border="0"> <xsl:if test="$list-width != ''"> <xsl:attribute name="width"> <xsl:value-of select="$list-width"/> </xsl:attribute> </xsl:if> <xsl:if test="$table-summary != ''"> <xsl:attribute name="summary"> <xsl:value-of select="$table-summary"/> </xsl:attribute> </xsl:if> <col align="left" valign="top"> <xsl:if test="$term-width != ''"> <xsl:attribute name="width"> <xsl:value-of select="$term-width"/> </xsl:attribute> </xsl:if> </col> <tbody> <xsl:apply-templates mode="varlist-table" select="varlistentry |comment()[preceding-sibling::varlistentry] |processing-instruction()[preceding-sibling::varlistentry]"/> </tbody> </table> </xsl:when> <!-- DWC: Adding support for new presentation type --> <xsl:when test="$presentation = 'runinhead'"> <!-- Preserve order of PIs and comments --> <xsl:apply-templates select="*[not(self::varlistentry or self::title or self::titleabbrev)] |comment()[not(preceding-sibling::varlistentry)] |processing-instruction()[not(preceding-sibling::varlistentry)]"/> <ul style="list-style-type: none"> <xsl:apply-templates select="varlistentry |comment()[preceding-sibling::varlistentry] |processing-instruction()[preceding-sibling::varlistentry]" mode="varlist-runinhead"/> </ul> </xsl:when> <xsl:otherwise> <!-- Preserve order of PIs and comments --> <xsl:apply-templates select="*[not(self::varlistentry or self::title or self::titleabbrev)] |comment()[not(preceding-sibling::varlistentry)] |processing-instruction()[not(preceding-sibling::varlistentry)]"/> <dl> <xsl:apply-templates select="varlistentry |comment()[preceding-sibling::varlistentry] |processing-instruction()[preceding-sibling::varlistentry]"/> </dl> </xsl:otherwise> </xsl:choose> </div> </xsl:template> <!-- DWC: added the following templates to add support for runinhead varlist style --> <xsl:template match="varlistentry" mode="varlist-runinhead"> <li> <xsl:call-template name="anchor"/> <p> <xsl:apply-templates select="term" mode="varlist-runinhead"/> <xsl:apply-templates select="listitem/para[1]" mode="varlist-runinhead"/> </p> <xsl:apply-templates select="listitem" mode="varlist-runinhead"/> </li> </xsl:template> <xsl:template match="term" mode="varlist-runinhead"> <xsl:variable name="titleStr"> <xsl:apply-templates/> </xsl:variable> <xsl:variable name="lastChar"> <xsl:if test="$titleStr != ''"> <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/> </xsl:if> </xsl:variable> <b> <xsl:copy-of select="$titleStr"/> <xsl:if test="$lastChar != '' and not(contains($runinhead.title.end.punct, $lastChar))"> <xsl:value-of select="$runinhead.default.title.end.punct"/> </xsl:if> <xsl:text> </xsl:text> </b> </xsl:template> <xsl:template match="listitem" mode="varlist-runinhead"> <xsl:choose> <xsl:when test="*[1][self::para]"> <xsl:apply-templates select="*[position() > 1]"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="para" mode="varlist-runinhead"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]