From: Taj M. <taj...@us...> - 2004-09-12 20:14:48
|
Update of /cvsroot/davinci/docs/xls/manpages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25978/xls/manpages Added Files: ChangeLog README docbook.xsl lists.xsl sect23.xsl synop.xsl xref.xsl Log Message: Added XSL support files --- NEW FILE: lists.xsl --- <?xml version='1.0'?> <!-- vim:set sts=2 shiftwidth=2 syntax=sgml: --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:template match="para[ancestor::listitem or ancestor::step]| simpara[ancestor::listitem or ancestor::step]| remark[ancestor::listitem or ancestor::step]"> <xsl:for-each select="node()"> <xsl:choose> <xsl:when test="self::literallayout|self::screen|self::programlisting| self::itemizedlist|self::orderedlist|self::variablelist| self::simplelist"> <xsl:text> </xsl:text> <xsl:apply-templates select="."/> </xsl:when> <xsl:when test="self::text()"> <xsl:if test="starts-with(translate(.,' ',' '), ' ') and preceding-sibling::node()[name(.)!='']"> <xsl:text> </xsl:text> </xsl:if> <xsl:variable name="content"> <xsl:apply-templates select="."/> </xsl:variable> <xsl:value-of select="normalize-space($content)"/> <xsl:if test="translate(substring(., string-length(.), 1),' ',' ') = ' ' and following-sibling::node()[name(.)!='']"> <xsl:text> </xsl:text> </xsl:if> </xsl:when> <xsl:otherwise> <xsl:variable name="content"> <xsl:apply-templates select="."/> </xsl:variable> <xsl:value-of select="normalize-space($content)"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text> </xsl:text> <xsl:if test="following-sibling::para or following-sibling::simpara or following-sibling::remark"> <!-- Make sure multiple paragraphs within a list item don't --> <!-- merge together. --> <xsl:text> </xsl:text> </xsl:if> </xsl:template> <xsl:template match="varlistentry|glossentry"> <xsl:text> .TP </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="variablelist[ancestor::listitem or ancestor::step]| glosslist[ancestor::listitem or ancestor::step]"> <xsl:text> .RS </xsl:text> <xsl:apply-templates/> <xsl:text> .RE .IP </xsl:text> </xsl:template> <xsl:template match="varlistentry/term|glossterm"> <xsl:variable name="content"> <xsl:apply-templates/> </xsl:variable> <xsl:value-of select="normalize-space($content)"/> <xsl:text>, </xsl:text> </xsl:template> <xsl:template match="varlistentry/term[position()=last()]|glossterm[position()=last()]" priority="2"> <xsl:variable name="content"> <xsl:apply-templates/> </xsl:variable> <xsl:value-of select="normalize-space($content)"/> </xsl:template> <xsl:template match="varlistentry/listitem|glossdef"> <xsl:text> </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="itemizedlist/listitem"> <xsl:text>\(bu </xsl:text> <xsl:apply-templates/> <xsl:if test="following-sibling::listitem"> <xsl:text>.TP </xsl:text> </xsl:if> </xsl:template> <xsl:template match="orderedlist/listitem|procedure/step"> <xsl:number format="1."/> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:if test="position()!=last()"> <xsl:text>.TP </xsl:text> </xsl:if> </xsl:template> <xsl:template match="itemizedlist|orderedlist|procedure"> <xsl:text> .TP 3 </xsl:text> <xsl:apply-templates/> <xsl:text>.LP </xsl:text> </xsl:template> <xsl:template match="itemizedlist[ancestor::listitem or ancestor::step]| orderedlist[ancestor::listitem or ancestor::step]| procedure[ancestor::listitem or ancestor::step]"> <xsl:text> .RS .TP 3 </xsl:text> <xsl:apply-templates/> <xsl:text>.LP .RE .IP </xsl:text> </xsl:template> <!-- simplelist --> <xsl:template match="simplelist[@type='inline']"> <xsl:apply-templates/> </xsl:template> <xsl:template match="simplelist[@type='inline']/member"> <xsl:apply-templates/> <xsl:text>, </xsl:text> </xsl:template> <xsl:template match="simplelist[@type='inline']/member[position()=last()]" priority="2"> <xsl:apply-templates/> </xsl:template> <xsl:template match="simplelist[@type='vert' and @columns='1']"> <xsl:text> .IP </xsl:text> <xsl:apply-templates/> <xsl:text>.LP </xsl:text> </xsl:template> <xsl:template match="simplelist[@type='vert' and @columns='1']/member"> <xsl:apply-templates/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> --- NEW FILE: synop.xsl --- <?xml version='1.0'?> <!-- vim:set sts=2 shiftwidth=2 syntax=sgml: --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:template match="synopfragment"> <xsl:text> .PP </xsl:text> <xsl:apply-templates/> </xsl:template> <!-- there's a bug were an <arg> that's not inside a <group> isn't made bold --> <xsl:template match="group|arg"> <xsl:variable name="choice" select="@choice"/> <xsl:variable name="rep" select="@rep"/> <xsl:variable name="sepchar"> <xsl:choose> <xsl:when test="ancestor-or-self::*/@sepchar"> <xsl:value-of select="ancestor-or-self::*/@sepchar"/> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:if test="position()>1"><xsl:value-of select="$sepchar"/></xsl:if> <xsl:choose> <xsl:when test="$choice='plain'"> <!-- do nothing --> </xsl:when> <xsl:when test="$choice='req'"> <xsl:value-of select="$arg.choice.req.open.str"/> </xsl:when> <xsl:when test="$choice='opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$arg.choice.def.open.str"/> </xsl:otherwise> </xsl:choose> <xsl:variable name="arg"> <xsl:apply-templates/> </xsl:variable> <xsl:choose> <xsl:when test="local-name(.) = 'arg' and not(ancestor::arg)"> <!-- Prevent breaking up an argument by wrapping it --> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="normalize-space($arg)"/> <xsl:with-param name="replace" select="' '"/> <xsl:with-param name="with" select="'\ '"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="normalize-space($arg)"/> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="$rep='repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/> </xsl:when> <xsl:when test="$rep='norepeat'"> <xsl:value-of select="$arg.rep.norepeat.str"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$arg.rep.def.str"/> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="$choice='plain'"> <xsl:if test='arg'> <xsl:value-of select="$arg.choice.plain.close.str"/> </xsl:if> </xsl:when> <xsl:when test="$choice='req'"> <xsl:value-of select="$arg.choice.req.close.str"/> </xsl:when> <xsl:when test="$choice='opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$arg.choice.def.close.str"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="group/arg"> <xsl:if test="position()>1"> <xsl:value-of select="$arg.or.sep"/> </xsl:if> <!-- Don't use the 'bold' named template here since there may be --> <!-- child elements that require different markup (such as --> <!-- <replaceable>). --> <xsl:text>\fB</xsl:text> <xsl:variable name="arg"> <xsl:apply-templates/> </xsl:variable> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="normalize-space($arg)"/> <xsl:with-param name="replace" select="' '"/> <xsl:with-param name="with" select="'\ '"/> </xsl:call-template> <xsl:text>\fR</xsl:text> </xsl:template> <xsl:template match="command"> <xsl:apply-templates mode="bold" select="."/> </xsl:template> <xsl:template match="function[not(ancestor::command)]"> <xsl:apply-templates mode="bold" select="."/> </xsl:template> <xsl:template match="parameter[not(ancestor::command)]"> <xsl:apply-templates mode="italic" select="."/> </xsl:template> <xsl:template match="sbr" /> <xsl:template match="cmdsynopsis"> <xsl:text>.ad l .hy 0 </xsl:text> <xsl:text>.HP </xsl:text> <xsl:value-of select="string-length (normalize-space (command)) + 1"/> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:text> .ad .hy </xsl:text> </xsl:template> <xsl:template match="synopsis"> <xsl:text> .nf </xsl:text> <xsl:apply-templates/> <xsl:text> .fi </xsl:text> </xsl:template> <xsl:template match="void"> <xsl:text>void</xsl:text> </xsl:template> <xsl:template match="varargs"> <xsl:text>...</xsl:text> </xsl:template> <xsl:template match="funcsynopsisinfo"> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:text> .sp </xsl:text> </xsl:template> <!-- disable hyphenation, and use left-aligned filling for the duration of the synopsis, so that line breaks only occur between separate paramdefs. --> <xsl:template match="funcsynopsis"> <xsl:text>.ad l .hy 0 </xsl:text> <xsl:apply-templates/> <xsl:text>.ad .hy </xsl:text> </xsl:template> <!-- TODO: Handle K&R-style parameter lists Comment that used to go with the paramdef template, which is now obsolete and thus deleted --> <!-- replaces all spaces within the funcdef/paramdef with non-breaking spaces --> <xsl:template match="paramdef|funcdef"> <xsl:variable name="rcontent"> <xsl:apply-templates select="*|./*|text()"/> </xsl:variable> <xsl:variable name="content"> <xsl:value-of select="normalize-space($rcontent)"/> </xsl:variable> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="' '"/> <xsl:with-param name="with" select="'\ '"/> </xsl:call-template> <xsl:if test="local-name(.) = 'paramdef' and (following-sibling::paramdef or following-sibling::varargs)"> <xsl:text>, </xsl:text> </xsl:if> </xsl:template> <xsl:template match="funcprototype"> <xsl:variable name="funcprototype"> <xsl:apply-templates select="funcdef"/> </xsl:variable> <xsl:text>.HP </xsl:text> <xsl:value-of select="string-length (normalize-space ($funcprototype)) - 5"/> <xsl:text> </xsl:text> <xsl:value-of select="normalize-space ($funcprototype)"/> <xsl:text>\ (</xsl:text> <xsl:apply-templates select="void|paramdef|varargs"/> <xsl:text>); </xsl:text> </xsl:template> </xsl:stylesheet> --- NEW FILE: ChangeLog --- 2004-02-04 <tw...@us...> * docbook.xsl, lists.xsl: Place-holder implementation for simplelist. 2004-01-30 <tw...@us...> * docbook.xsl: Add replacement dingbat characters. 2003-12-24 <tw...@us...> * lists.xsl: .RS/.RE doesn't nest precisely. Use .IP to fix up the environment. Part of bug #852714. * lists.xsl: Handle comments inside lists (part of bug #852714). 2003-12-15 <tw...@us...> * lists.xsl: Fix nested lists properly. 2003-12-13 <tw...@us...> * docbook.xsl: Use .nf environment for literallayout. * docbook.xsl: Prevent duplicate .nf environments inside informalexample or screen. All fiftenn allowed contained element in these elements will provide its own. 2003-12-12 <tw...@us...> * docbook.xsl: Last commit reverted a previous change -- redo it. 2003-12-11 <tw...@us...> * docbook.xsl: Remove unused rule. * docbook.xsl: Fix literallayout inside para. * lists.xsl: Fix singly-nested lists. 2003-12-10 <tw...@us...> * docbook.xsl: Don't mess up roff markup in tables. 2003-11-06 <tw...@us...> * lists.xsl, synop.xsl: 2003-11-06 Tim Waugh <tw...@re...> * lists.xsl: Normalize space in itemizedlist/listitem. * synop.xsl: Likewise. 2003-05-23 <tw...@us...> * synop.xsl: Only escape option spaces once when args are nested. 2003-05-15 <tw...@us...> * docbook.xsl: Handle refsection as well as refsect1|refsect2 in the manpages stylesheet. 2003-05-09 Norman Walsh <nw...@us...> * synop.xsl, synop.xsl: Patch from Tim Waugh 2003-04-12 Norman Walsh <nw...@us...> * docbook.xsl, synop.xsl: Patches from Tim Waugh 2003-03-15 <jo...@us...> * docbook.xsl: If the refmeta contains no manvolnum, then: - if the refentry contains a funcsynopsis, default to section 3 - otherwise, default to section 1 * docbook.xsl: Don't try and generate man pages with spaces in the filename; replace spaces with underscores. 2003-01-05 <jo...@us...> * docbook.xsl: Second half of fix for #628888: add template for <optional>. * docbook.xsl: Add replacement ulink template from xmlto, fixing bug #619500. Written by Tim Waugh. * docbook.xsl: First part of fix for #628888: - don't use generic italic/bold templates for things like <replaceable>, since <replaceable> can contain other elements, but the templates discard any non-PCDATA content. * docbook.xsl: Prevent a line beginning with a '.' character being interpreted as a troff macro by inserting \& (a zero-width space) before every '.' in text. * xref.xsl: Make xref work again, though I'm not sure why it stopped working. 2002-09-20 Norman Walsh <nw...@us...> * synop.xsl: Joe Orton: Use replace-string from lib.xsl 2002-09-18 Norman Walsh <nw...@us...> * db2man.xsl, docbook.xsl: Renamed * docbook.xsl: Joe Orton: patch to get rid of extra whitespace in author names 2002-09-17 Norman Walsh <nw...@us...> * db2man.xsl: Another patch from Joe Orton * db2man.xsl, synop.xsl: Patch from Joe Orton 2002-07-04 Norman Walsh <nw...@us...> * README, db2man.xsl, lists.xsl, sect23.xsl, synop.xsl, xref.xsl: New file. --- NEW FILE: README --- README for db2man by Martijn van Beers (lo...@us...) I've been working on some stylesheets to convert <refentry>s to man format. I thought I'd submit what I have for inclusion in the docbook-xsl package. See also: http://sourceforge.net/tracker/index.php?func=detail&aid=468779&group_id=21935&atid=373749 --- NEW FILE: sect23.xsl --- <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:template match="refsect2"> <xsl:text> .Sh "</xsl:text> <xsl:value-of select="substring-before(title[1],' ')"/> <xsl:text>" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="refsect2/title"></xsl:template> <xsl:template match="refsect2/programlisting"></xsl:template> <xsl:template match="funcsynopsis"> <xsl:text> .BI "</xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="funcsynopsis/funcprototype"> <xsl:apply-templates/> <xsl:text> ); .br </xsl:text> </xsl:template> <xsl:template match="funcsynopsis/funcprototype/funcdef"> <xsl:apply-templates/> <xsl:value-of select="function"/> <xsl:text> (</xsl:text> </xsl:template> <xsl:template match="funcsynopsis/funcprototype/funcdef/function"></xsl:template> <xsl:template match="funcsynopsis/funcprototype/paramdef"> <xsl:apply-templates/> <xsl:text>" </xsl:text> <xsl:value-of select="parameter"/> <xsl:choose> <xsl:when test="following-sibling::paramdef"> <xsl:text> ", </xsl:text> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="funcsynopsis/funcprototype/paramdef/parameter"></xsl:template> <xsl:template match="refsect2/informaltable/tgroup/tbody/row"> <xsl:text>.Ip "\(bu \s-1</xsl:text> <xsl:value-of select="entry[1]/parameter[1]"/> <xsl:text>\s0 \- </xsl:text> <xsl:value-of select="normalize-space(entry[2])"/> <xsl:text>" </xsl:text> </xsl:template> <xsl:template match="refsect1"> <xsl:text> .SH "</xsl:text> <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> <xsl:text>" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="refsynopsisdiv"> <xsl:text> .SH "</xsl:text> <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> <xsl:text>" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="refsynopsisdiv/title"></xsl:template> <xsl:template match="refsect1/title"></xsl:template> <xsl:template match="para"> <xsl:text>.PP </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="*"><xsl:apply-templates/></xsl:template> <xsl:template match="refentry"> <xsl:text>." DO NOT MODIFY THIS FILE! .de Sh \" Subsection .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Ip \" List item .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .TH "</xsl:text> <xsl:value-of select="refmeta/refentrytitle[1]"/> <xsl:text>" </xsl:text> <xsl:value-of select="refmeta/manvolnum[1]"/> <xsl:text> "</xsl:text> <xsl:value-of select="@revision"/> <xsl:text>" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="refmeta"></xsl:template> <xsl:template match="refnamediv"> <xsl:text>.SH NAME </xsl:text> <xsl:value-of select="refname"/> <xsl:text> \- </xsl:text> <xsl:value-of select="refpurpose"/> </xsl:template> <xsl:template match="refentry/refentrytitle"></xsl:template> <xsl:template match="article/articleinfo/*"></xsl:template> <xsl:template match="term/option"> <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text> </xsl:template> <xsl:template match="varlistentry"> <xsl:text> .TP </xsl:text> <xsl:apply-templates select="./term"/> <xsl:apply-templates select="./listitem"/> </xsl:template> <xsl:template match="varlistentry/listitem/para"> <xsl:apply-templates/> </xsl:template> <xsl:template match="filename"> <xsl:text> .FN </xsl:text><xsl:apply-templates/> </xsl:template> <xsl:template match="userinput"> <xsl:text> .IP .B </xsl:text><xsl:apply-templates/> </xsl:template> <xsl:template match="envar"> <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text> </xsl:template> <xsl:template match="filename"> <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text> </xsl:template> </xsl:stylesheet> --- NEW FILE: xref.xsl --- <?xml version='1.0'?> <!-- vim:set sts=2 shiftwidth=2 syntax=sgml: --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:template match="xref"> <xsl:variable name="targets" select="key('id', @linkend)"/> <xsl:variable name="target" select="$targets[1]"/> <xsl:variable name="type" select="local-name($target)"/> <xsl:choose> <xsl:when test="$type=''"> <xsl:message> <xsl:text>xref to nonexistent id </xsl:text> <xsl:value-of select="@linkend"/> </xsl:message> </xsl:when> <xsl:when test="$type='refentry'"> <xsl:call-template name="do-citerefentry"> <xsl:with-param name="refentrytitle" select="$target/refmeta/refentrytitle[1]"/> <xsl:with-param name="manvolnum" select="$target/refmeta/manvolnum"/> </xsl:call-template> </xsl:when> <xsl:when test="$type='refname'"> <xsl:call-template name="do-citerefentry"> <xsl:with-param name="refentrytitle" select="$target"/> <xsl:with-param name="manvolnum" select="$target/../../refmeta/manvolnum"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:text>[xref to </xsl:text> <xsl:value-of select="$type"/> <xsl:text>]</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> --- NEW FILE: docbook.xsl --- <?xml version='1.0'?> <!-- vim:set sts=2 shiftwidth=2 syntax=sgml: --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:import href="../html/docbook.xsl"/> <xsl:include href="synop.xsl"/> <xsl:include href="lists.xsl"/> <xsl:include href="xref.xsl"/> <!-- Needed for chunker.xsl (for now): --> <xsl:param name="chunker.output.method" select="'text'"/> <xsl:param name="chunker.output.encoding" select="'ISO-8859-1'"/> <xsl:output method="text" encoding="ISO-8859-1" indent="no"/> <!-- named templates for bold and italic. call like: <xsl:apply-templates mode="bold" select="node-you-want" /> --> <xsl:template mode="bold" match="*"> <xsl:variable name="content"> <xsl:apply-templates/> </xsl:variable> <xsl:text>\fB</xsl:text> <xsl:value-of select="$content"/> <xsl:text>\fR</xsl:text> </xsl:template> <xsl:template mode="italic" match="*"> <xsl:variable name="content"> <xsl:apply-templates/> </xsl:variable> <xsl:text>\fI</xsl:text> <xsl:value-of select="$content"/> <xsl:text>\fR</xsl:text> </xsl:template> <xsl:template match="caution|important|note|tip|warning"> <xsl:text> .RS .Sh "</xsl:text> <!-- capitalize word --> <xsl:value-of select="translate (substring (name(.), 1, 1), 'cintw', 'CINTW')" /> <xsl:value-of select="substring (name(), 2)" /> <xsl:if test="title"> <xsl:text>: </xsl:text> <xsl:value-of select="title[1]"/> </xsl:if> <xsl:text>" </xsl:text> <xsl:apply-templates/> <xsl:text> .RE </xsl:text> </xsl:template> <xsl:template match="refsection|refsect1"> <xsl:choose> <xsl:when test="ancestor::refsection"> <xsl:text> .SS "</xsl:text> <xsl:value-of select="title[1]"/> </xsl:when> <xsl:otherwise> <xsl:text> .SH "</xsl:text> <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="refsect2"> <xsl:text> .SS "</xsl:text> <xsl:value-of select="title[1]"/> <xsl:text>" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="refsynopsisdiv"> <xsl:text> .SH "SYNOPSIS" </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="para"> <xsl:text> .PP </xsl:text> <xsl:for-each select="node()"> <xsl:choose> <xsl:when test="self::literallayout|self::informaltable|self::screen| self::programlisting|self::itemizedlist| self::orderedlist|self::variablelist|self::simplelist"> <xsl:text> </xsl:text> <xsl:apply-templates select="."/> </xsl:when> <xsl:when test="self::text()"> <xsl:if test="starts-with(translate(.,' ',' '), ' ') and preceding-sibling::node()[name(.)!='']"> <xsl:text> </xsl:text> </xsl:if> <xsl:variable name="content"> <xsl:apply-templates select="."/> </xsl:variable> <xsl:value-of select="normalize-space($content)"/> <xsl:if test="translate(substring(., string-length(.), 1),' ',' ') = ' ' and following-sibling::node()[name(.)!='']"> <xsl:text> </xsl:text> </xsl:if> </xsl:when> <xsl:otherwise> <xsl:variable name="content"> <xsl:apply-templates select="."/> </xsl:variable> <xsl:value-of select="normalize-space($content)"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text> </xsl:text> </xsl:template> <xsl:template match="simpara"> <xsl:variable name="content"> <xsl:apply-templates/> </xsl:variable> <xsl:text> </xsl:text> <xsl:value-of select="normalize-space($content)"/> <xsl:text> </xsl:text> </xsl:template> <xsl:template match="refentry"> <xsl:variable name="section"> <xsl:choose> <xsl:when test="refmeta/manvolnum"> <xsl:value-of select="refmeta/manvolnum[1]"/> </xsl:when> <xsl:when test=".//funcsynopsis">3</xsl:when> <xsl:otherwise>1</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="name" select="refnamediv/refname[1]"/> <!-- standard man page width is 64 chars; 6 chars needed for the two (x) volume numbers, and 2 spaces, leaves 56 --> <xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/> <xsl:variable name="reftitle" select="substring(refmeta/refentrytitle, 1, $twidth)"/> <xsl:variable name="title"> <xsl:choose> <xsl:when test="refentryinfo/title"> <xsl:value-of select="refentryinfo/title"/> </xsl:when> <xsl:when test="../referenceinfo/title"> <xsl:value-of select="../referenceinfo/title"/> </xsl:when> </xsl:choose> </xsl:variable> <xsl:variable name="date"> <xsl:choose> <xsl:when test="refentryinfo/date"> <xsl:value-of select="refentryinfo/date"/> </xsl:when> <xsl:when test="../referenceinfo/date"> <xsl:value-of select="../referenceinfo/date"/> </xsl:when> </xsl:choose> </xsl:variable> <xsl:variable name="productname"> <xsl:choose> <xsl:when test="refentryinfo/productname"> <xsl:value-of select="refentryinfo/productname"/> </xsl:when> <xsl:when test="../referenceinfo/productname"> <xsl:value-of select="../referenceinfo/productname"/> </xsl:when> </xsl:choose> </xsl:variable> <!-- replace spaces with underscores in the filename --> <xsl:variable name="filename"> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="concat(normalize-space ($name), '.', $section)"/> <xsl:with-param name="replace" select="' '"/> <xsl:with-param name="with" select="'_'"/> </xsl:call-template> </xsl:variable> <xsl:call-template name="write.text.chunk"> <xsl:with-param name="filename" select="$filename"/> <xsl:with-param name="content"> <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source. .de Sh \" Subsection .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Ip \" List item .br .ie \\n(.$>=3 .ne \\$3 .el .ne 3 .IP "\\$1" \\$2 .. .TH "</xsl:text> <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> <xsl:text>" </xsl:text> <xsl:value-of select="$section"/> <xsl:text> "</xsl:text> <xsl:value-of select="normalize-space($date)"/> <xsl:text>" "</xsl:text> <xsl:value-of select="normalize-space($productname)"/> <xsl:text>" "</xsl:text> <xsl:value-of select="$title"/> <xsl:text>" </xsl:text> <xsl:apply-templates/> <xsl:text> </xsl:text> <!-- Author section --> <xsl:choose> <xsl:when test="refentryinfo//author"> <xsl:apply-templates select="refentryinfo" mode="authorsect"/> </xsl:when> <xsl:when test="/book/bookinfo//author"> <xsl:apply-templates select="/book/bookinfo" mode="authorsect"/> </xsl:when> <xsl:when test="/article/articleinfo//author"> <xsl:apply-templates select="/article/articleinfo" mode="authorsect"/> </xsl:when> </xsl:choose> </xsl:with-param> </xsl:call-template> <!-- Now generate stub include pages for every page documented in this refentry (except the page itself) --> <xsl:for-each select="refnamediv/refname"> <xsl:if test=". != $name"> <xsl:call-template name="write.text.chunk"> <xsl:with-param name="filename" select="concat(normalize-space(.), '.', $section)"/> <xsl:with-param name="content" select="concat('.so man', $section, '/', $name, '.', $section, ' ')"/> </xsl:call-template> </xsl:if> </xsl:for-each> </xsl:template> <xsl:template match="refmeta"></xsl:template> <xsl:template match="title"></xsl:template> <xsl:template match="abstract"></xsl:template> <xsl:template match="articleinfo|bookinfo|refentryinfo" mode="authorsect"> <xsl:text>.SH AUTHOR</xsl:text> <xsl:if test="count(.//author)>1"> <xsl:text>S</xsl:text> </xsl:if> <xsl:text> </xsl:text> <xsl:for-each select=".//author"> <xsl:if test="position() > 1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:variable name="author"> <xsl:apply-templates select="."/> </xsl:variable> <xsl:value-of select="normalize-space($author)"/> </xsl:for-each> <xsl:text>. </xsl:text> <xsl:if test=".//editor"> <xsl:text>.br Man page edited by </xsl:text> <xsl:apply-templates select=".//editor"/> <xsl:text>. </xsl:text> </xsl:if> </xsl:template> <xsl:template match="author|editor"> <xsl:call-template name="person.name"/> <xsl:apply-templates select="./affiliation/address/email" /> </xsl:template> <xsl:template match="copyright"> <xsl:text>Copyright \(co </xsl:text> <xsl:apply-templates select="./year" /> <xsl:text> .Sp </xsl:text> </xsl:template> <xsl:template match="email"> <xsl:text> <</xsl:text> <xsl:apply-templates/> <xsl:text>></xsl:text> </xsl:template> <xsl:template match="refnamediv"> <xsl:text>.SH NAME </xsl:text> <xsl:for-each select="refname"> <xsl:if test="position()>1"> <xsl:text>, </xsl:text> </xsl:if> <xsl:value-of select="."/> </xsl:for-each> <xsl:text> \- </xsl:text> <xsl:value-of select="normalize-space (refpurpose)"/> </xsl:template> <xsl:template match="refentry/refentryinfo"></xsl:template> <xsl:template match="informalexample|screen"> <xsl:text> .IP </xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="filename|replaceable|varname"> <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text> </xsl:template> <xsl:template match="option|userinput|envar|errorcode|constant|type"> <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text> </xsl:template> <xsl:template match="quote"> <xsl:text>``</xsl:text> <xsl:apply-templates/> <xsl:text>''</xsl:text> </xsl:template> <xsl:template match="programlisting|literallayout"> <xsl:text> .nf </xsl:text> <xsl:apply-templates/> <xsl:text> .fi </xsl:text> </xsl:template> <xsl:template match="optional"> <xsl:value-of select="$arg.choice.opt.open.str"/> <xsl:apply-templates/> <xsl:value-of select="$arg.choice.opt.close.str"/> </xsl:template> <xsl:template name="do-citerefentry"> <xsl:param name="refentrytitle" select="''"/> <xsl:param name="manvolnum" select="''"/> <xsl:apply-templates mode="bold" select="$refentrytitle"/> <xsl:text>(</xsl:text> <xsl:value-of select="$manvolnum"/> <xsl:text>)</xsl:text> </xsl:template> <xsl:template match="citerefentry"> <xsl:call-template name="do-citerefentry"> <xsl:with-param name="refentrytitle" select="refentrytitle"/> <xsl:with-param name="manvolnum" select="manvolnum"/> </xsl:call-template> </xsl:template> <xsl:template match="ulink"> <xsl:variable name="content"> <xsl:apply-templates/> </xsl:variable> <xsl:variable name="url" select="@url"/> <xsl:choose> <xsl:when test="$url=$content or $content=''"> <xsl:text>\fI</xsl:text> <xsl:value-of select="$url"/> <xsl:text>\fR</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="$content"/> <xsl:text>: \fI</xsl:text> <xsl:value-of select="$url"/> <xsl:text>\fR</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- Translate some entities to textual equivalents. --> <xsl:template name="replace-string"> <xsl:param name="content" select="''"/> <xsl:param name="replace" select="''"/> <xsl:param name="with" select="''"/> <xsl:choose> <xsl:when test="not(contains($content,$replace))"> <xsl:value-of select="$content"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring-before($content,$replace)"/> <xsl:value-of select="$with"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="substring-after($content,$replace)"/> <xsl:with-param name="replace" select="$replace"/> <xsl:with-param name="with" select="$with"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="replace-dash"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'-'"/> <xsl:with-param name="with" select="'\-'"/> </xsl:call-template> </xsl:template> <xsl:template name="replace-ndash"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'–'"/> <xsl:with-param name="with" select="'-'"/> </xsl:call-template> </xsl:template> <xsl:template name="replace-mdash"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'—'"/> <xsl:with-param name="with" select="'--'"/> </xsl:call-template> </xsl:template> <xsl:template name="replace-hellip"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'…'"/> <xsl:with-param name="with" select="'...'"/> </xsl:call-template> </xsl:template> <xsl:template name="replace-setmn"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'∖'"/> <xsl:with-param name="with" select="'\\'"/> </xsl:call-template> </xsl:template> <xsl:template name="replace-minus"> <xsl:param name="content" select="''"/> <xsl:value-of select="translate($content,'−','-')"/> </xsl:template> <xsl:template name="replace-backslash"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'\'"/> <xsl:with-param name="with" select="'\\'"/> </xsl:call-template> </xsl:template> <!-- if a period character is output at the beginning of a line it will be interpreted as a groff macro, so prefix all periods with "\&", a zero-width space. --> <xsl:template name="replace-period"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-string"> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="replace" select="'.'"/> <xsl:with-param name="with" select="'\&.'"/> </xsl:call-template> </xsl:template> <xsl:template name="replace-entities"> <xsl:param name="content" select="''"/> <xsl:call-template name="replace-hellip"> <xsl:with-param name="content"> <xsl:call-template name="replace-minus"> <xsl:with-param name="content"> <xsl:call-template name="replace-mdash"> <xsl:with-param name="content"> <xsl:call-template name="replace-ndash"> <xsl:with-param name="content"> <xsl:call-template name="replace-dash"> <xsl:with-param name="content"> <xsl:call-template name="replace-setmn"> <xsl:with-param name="content"> <xsl:call-template name="replace-period"> <xsl:with-param name="content"> <xsl:call-template name="replace-backslash"> <xsl:with-param name="content" select="$content"/> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template match="dingbat.characters"> <!-- now that I'm using the real serializer, all that dingbat malarky --> <!-- isn't necessary anymore... --> <xsl:param name="dingbat">bullet</xsl:param> <xsl:choose> <xsl:when test="$dingbat='bullet'">\(bu</xsl:when> <xsl:when test="$dingbat='copyright'">\(co</xsl:when> <xsl:when test="$dingbat='trademark'">\(tm</xsl:when> <xsl:when test="$dingbat='trade'">\(tm</xsl:when> <xsl:when test="$dingbat='registered'">\(rg</xsl:when> <xsl:when test="$dingbat='service'">(SM)</xsl:when> <xsl:when test="$dingbat='nbsp'"> </xsl:when> <xsl:when test="$dingbat='ldquo'">\(lq</xsl:when> <xsl:when test="$dingbat='rdquo'">\(rq</xsl:when> <xsl:when test="$dingbat='lsquo'">`</xsl:when> <xsl:when test="$dingbat='rsquo'">'</xsl:when> <xsl:when test="$dingbat='em-dash'">\(em</xsl:when> <xsl:when test="$dingbat='mdash'">\(em</xsl:when> <xsl:when test="$dingbat='en-dash'">\(en</xsl:when> <xsl:when test="$dingbat='ndash'">\(en</xsl:when> <xsl:otherwise> <xsl:text>\(bu</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="text()"> <xsl:call-template name="replace-entities"> <xsl:with-param name="content"> <xsl:value-of select="."/> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template match="/"> <xsl:choose> <xsl:when test="//refentry"> <xsl:apply-templates select="//refentry"/> </xsl:when> <xsl:otherwise> <xsl:message>No refentry elements!</xsl:message> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> |