|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
xmlns:exsl="http://exslt.org/common"
|
|
Packit Service |
76cb02 |
exclude-result-prefixes="exsl"
|
|
Packit Service |
76cb02 |
version='1.0'>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
XSLT Stylesheet DocBook -> LaTeX
|
|
Packit Service |
76cb02 |
############################################################################ -->
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:param name="listings.xml"/>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:template name="line.pad">
|
|
Packit Service |
76cb02 |
<xsl:param name="count"/>
|
|
Packit Service |
76cb02 |
<xsl:if test="$count > 0">
|
|
Packit Service |
76cb02 |
<xsl:text> </xsl:text>
|
|
Packit Service |
76cb02 |
<xsl:call-template name="line.pad">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="count" select="$count - 1"/>
|
|
Packit Service |
76cb02 |
</xsl:call-template>
|
|
Packit Service |
76cb02 |
</xsl:if>
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:template name="insert.co">
|
|
Packit Service |
76cb02 |
<xsl:param name="text"/>
|
|
Packit Service |
76cb02 |
<xsl:param name="areas"/>
|
|
Packit Service |
76cb02 |
<xsl:param name="areaid" select="'1'"/>
|
|
Packit Service |
76cb02 |
<xsl:param name="line" select="'1'"/>
|
|
Packit Service |
76cb02 |
<xsl:param name="col" select="'1'"/>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="area" select="$areas[position()=$areaid]"/>
|
|
Packit Service |
76cb02 |
<xsl:variable name="arealine">
|
|
Packit Service |
76cb02 |
<xsl:choose>
|
|
Packit Service |
76cb02 |
<xsl:when test="contains($area/@coords, ' ')">
|
|
Packit Service |
76cb02 |
<xsl:value-of select="substring-before($area/@coords, ' ')"/>
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:otherwise>
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$area/@coords"/>
|
|
Packit Service |
76cb02 |
</xsl:otherwise>
|
|
Packit Service |
76cb02 |
</xsl:choose>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
<xsl:variable name="areacol" select="substring-after($area/@coords, ' ')"/>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:choose>
|
|
Packit Service |
76cb02 |
<xsl:when test="string-length($text)=0">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:when test="not($area)">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$text"/>
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:when test="$arealine > $line">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:value-of select="substring-before($text, '
')"/>
|
|
Packit Service |
76cb02 |
<xsl:text>
</xsl:text>
|
|
Packit Service |
76cb02 |
<xsl:call-template name="insert.co">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="text" select="substring-after($text, '
')"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="line" select="$line+1"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="areaid" select="$areaid"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="areas" select="$areas"/>
|
|
Packit Service |
76cb02 |
</xsl:call-template>
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:otherwise>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="strlen">
|
|
Packit Service |
76cb02 |
<xsl:choose>
|
|
Packit Service |
76cb02 |
<xsl:when test="contains($text, '
')">
|
|
Packit Service |
76cb02 |
<xsl:value-of select="string-length(substring-before($text, '
'))"/>
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:otherwise>
|
|
Packit Service |
76cb02 |
<xsl:value-of select="string-length($text)"/>
|
|
Packit Service |
76cb02 |
</xsl:otherwise>
|
|
Packit Service |
76cb02 |
</xsl:choose>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="colpos">
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$areacol - $col"/>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="padlen">
|
|
Packit Service |
76cb02 |
<xsl:choose>
|
|
Packit Service |
76cb02 |
<xsl:when test="$areacol!='' and ($colpos > $strlen)">
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$colpos - $strlen"/>
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:otherwise>
|
|
Packit Service |
76cb02 |
<xsl:value-of select="'0'"/>
|
|
Packit Service |
76cb02 |
</xsl:otherwise>
|
|
Packit Service |
76cb02 |
</xsl:choose>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="count">
|
|
Packit Service |
76cb02 |
<xsl:choose>
|
|
Packit Service |
76cb02 |
<xsl:when test="$areacol='' or ($padlen > 0)">
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$strlen"/>
|
|
Packit Service |
76cb02 |
</xsl:when>
|
|
Packit Service |
76cb02 |
<xsl:otherwise>
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$colpos"/>
|
|
Packit Service |
76cb02 |
</xsl:otherwise>
|
|
Packit Service |
76cb02 |
</xsl:choose>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:if test="$count > 0">
|
|
Packit Service |
76cb02 |
<xsl:value-of select="substring($text,1,$count)"/>
|
|
Packit Service |
76cb02 |
</xsl:if>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:if test="$padlen > 0">
|
|
Packit Service |
76cb02 |
<xsl:call-template name="line.pad">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="count" select="$padlen"/>
|
|
Packit Service |
76cb02 |
</xsl:call-template>
|
|
Packit Service |
76cb02 |
</xsl:if>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<co>
|
|
Packit Service |
76cb02 |
<xsl:for-each select="$area/@id|$area/@xml:id|$area/@linkends">
|
|
Packit Service |
76cb02 |
<xsl:copy/></xsl:for-each>
|
|
Packit Service |
76cb02 |
</co>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:call-template name="insert.co">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="text" select="substring($text,$count+1)"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="line" select="$line"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="areaid" select="$areaid+1"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="areas" select="$areas"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="col" select="$col+$count"/>
|
|
Packit Service |
76cb02 |
</xsl:call-template>
|
|
Packit Service |
76cb02 |
</xsl:otherwise>
|
|
Packit Service |
76cb02 |
</xsl:choose>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:template match="programlisting|screen" mode="build.listing.co">
|
|
Packit Service |
76cb02 |
<xsl:param name="listing"/>
|
|
Packit Service |
76cb02 |
<xsl:param name="areas"/>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="content">
|
|
Packit Service |
76cb02 |
<xsl:apply-templates mode="latex.programlisting"/>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:element name="{local-name($listing)}">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:for-each select="$listing/@*">
|
|
Packit Service |
76cb02 |
<xsl:copy/>
|
|
Packit Service |
76cb02 |
</xsl:for-each>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:call-template name="insert.co">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="text" select="$content"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="areas" select="$areas"/>
|
|
Packit Service |
76cb02 |
</xsl:call-template>
|
|
Packit Service |
76cb02 |
</xsl:element>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:template match="programlistingco|screenco">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="newlisting">
|
|
Packit Service |
76cb02 |
<xsl:apply-templates select="programlisting|screen" mode="build.listing.co">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="listing" select="programlisting|screen"/>
|
|
Packit Service |
76cb02 |
<xsl:with-param name="areas" select="areaspec//area"/>
|
|
Packit Service |
76cb02 |
</xsl:apply-templates>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
<xsl:apply-templates select="exsl:node-set($newlisting)/*">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="rnode" select="calloutlist"/>
|
|
Packit Service |
76cb02 |
</xsl:apply-templates>
|
|
Packit Service |
76cb02 |
<xsl:apply-templates select="calloutlist">
|
|
Packit Service |
76cb02 |
<xsl:with-param name="rnode" select="exsl:node-set($newlisting)"/>
|
|
Packit Service |
76cb02 |
</xsl:apply-templates>
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:template match="areaspec|areaset|area"/>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
environment. Since in XSLT 1.0 you cannot directly include text files, the
|
|
Packit Service |
76cb02 |
workaround is to load the data from a listings database file. -->
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
imagedata[@format='linespecific']|
|
|
Packit Service |
76cb02 |
inlinegraphic[@format='linespecific']"
|
|
Packit Service |
76cb02 |
mode="latex.programlisting">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:variable name="name" select="name(.)"/>
|
|
Packit Service |
76cb02 |
<xsl:variable name="lst.doc" select="document($listings.xml)"/>
|
|
Packit Service |
76cb02 |
<xsl:variable name="lst.id">
|
|
Packit Service |
76cb02 |
<xsl:apply-templates select="." mode="lstid"/>
|
|
Packit Service |
76cb02 |
</xsl:variable>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
select="$lst.doc/listings/listing[@type=$name][@lstid=$lst.id]"/>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:if test="$output.quietly = 0">
|
|
Packit Service |
76cb02 |
<xsl:message><xsl:text>Load external file </xsl:text>
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$name"/>
|
|
Packit Service |
76cb02 |
<xsl:text>[</xsl:text>
|
|
Packit Service |
76cb02 |
<xsl:value-of select="$lst.id"/>
|
|
Packit Service |
76cb02 |
<xsl:text>]</xsl:text>
|
|
Packit Service |
76cb02 |
<xsl:if test="not($lst.ext)">
|
|
Packit Service |
76cb02 |
<xsl:text>(failed)</xsl:text>
|
|
Packit Service |
76cb02 |
</xsl:if>
|
|
Packit Service |
76cb02 |
</xsl:message>
|
|
Packit Service |
76cb02 |
</xsl:if>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
<xsl:apply-templates mode="latex.programlisting" select="$lst.ext"/>
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
the templates in the same mode. -->
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
mode="latex.programlisting">
|
|
Packit Service |
76cb02 |
<xsl:apply-templates mode="latex.programlisting"/>
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
imagedata[@format='linespecific']|
|
|
Packit Service |
76cb02 |
inlinegraphic[@format='linespecific']" mode="lstid">
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
level="any"
|
|
Packit Service |
76cb02 |
format="1"/>
|
|
Packit Service |
76cb02 |
</xsl:template>
|
|
Packit Service |
76cb02 |
|
|
Packit Service |
76cb02 |
</xsl:stylesheet>
|