[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] variablelist styles
Thanks David, I also managed to get this working by creating a new listitem/para template similar to the simpara..so a <p> tag is not automatically applied to the listitem paragraph if the first child is a para. I had a harder time with the FO output, but I removed some of the blocks and replaced them with wrappers, and it works as well. I will however, give your suggestion a try, just in case it is cleaner ;). Kind Regards, Laurie. Laurie Burley Sr. Tech Comm Spc. Kofax U.K., Ltd. 201 Cambridge Science Park Milton Road, Cambridge CB4 0GZ United Kingdom Tel: +44 (0) 1223 226021 laurie.burley@kofax.com -----Original Message----- From: David Cramer [mailto:dcramer@motive.com] Sent: 11 February 2010 15:49 To: Laurie Burley; docbook-apps@lists.oasis-open.org; DeanNelson 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> ------------------------------------------------- This communication is only for the use of the intended recipient. It may contain confidential or proprietary information. If you are not the intended recipient or have received this communication in error, please notify the sender via phone and destroy this communication immediately.
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]