| 1 |
<?xml version='1.0'?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> |
| 3 |
|
| 4 |
<!--############################################################################ |
| 5 |
XSLT Stylesheet DocBook -> LaTeX |
| 6 |
############################################################################ --> |
| 7 |
|
| 8 |
<xsl:template name="scape" > |
| 9 |
<xsl:param name="string"/> |
| 10 |
<xsl:call-template name="tex-format"> |
| 11 |
<xsl:with-param name="string" select="$string"/> |
| 12 |
</xsl:call-template> |
| 13 |
</xsl:template> |
| 14 |
|
| 15 |
|
| 16 |
<!-- Text format template --> |
| 17 |
|
| 18 |
<xsl:template name="tex-format"> |
| 19 |
<xsl:param name="string"/> |
| 20 |
<xsl:call-template name="special-replace"> |
| 21 |
<xsl:with-param name="i">1</xsl:with-param> |
| 22 |
<xsl:with-param name="mapfile" select="document('texmap.xml')"/> |
| 23 |
<xsl:with-param name="string" select="$string"/> |
| 24 |
</xsl:call-template> |
| 25 |
</xsl:template> |
| 26 |
|
| 27 |
|
| 28 |
<!-- Special character replacement engine --> |
| 29 |
|
| 30 |
<xsl:template name="special-replace"> |
| 31 |
<xsl:param name="i"/> |
| 32 |
<xsl:param name="mapfile"/> |
| 33 |
<xsl:param name="string"/> |
| 34 |
<xsl:choose> |
| 35 |
<xsl:when test="($mapfile/mapping/map[position()=$i])[1]"> |
| 36 |
<xsl:variable name="map" select="($mapfile/mapping/map[position()=$i])[1]"/> |
| 37 |
<xsl:call-template name="string-replace"> |
| 38 |
<xsl:with-param name="to"> |
| 39 |
<xsl:value-of select="$map/@text"/></xsl:with-param> |
| 40 |
<xsl:with-param name="from"> |
| 41 |
<xsl:value-of select="$map/@key"/></xsl:with-param> |
| 42 |
<xsl:with-param name="string"> |
| 43 |
<xsl:call-template name="special-replace"> |
| 44 |
<xsl:with-param name="i" select="$i+1"/> |
| 45 |
<xsl:with-param name="mapfile" select="$mapfile"/> |
| 46 |
<xsl:with-param name="string" select="$string"/> |
| 47 |
</xsl:call-template> |
| 48 |
</xsl:with-param> |
| 49 |
</xsl:call-template> |
| 50 |
</xsl:when> |
| 51 |
<xsl:otherwise> |
| 52 |
<xsl:value-of select="$string"/> |
| 53 |
</xsl:otherwise> |
| 54 |
</xsl:choose> |
| 55 |
</xsl:template> |
| 56 |
|
| 57 |
|
| 58 |
<!-- map section to latex --> |
| 59 |
|
| 60 |
<xsl:template name="sec-map"> |
| 61 |
<xsl:param name="keyword"/> |
| 62 |
<xsl:param name="name" select="local-name(.)"/> |
| 63 |
<xsl:variable name="mapfile" select="document('secmap.xml')"/> |
| 64 |
<xsl:variable name="to" select="($mapfile/mapping/map[@key=$keyword])[1]/@text"/> |
| 65 |
<xsl:if test="$to=''"> |
| 66 |
<xsl:message>*** No mapping for <xsl:value-of select="$keyword"/></xsl:message> |
| 67 |
</xsl:if> |
| 68 |
<xsl:value-of select="$to"/> |
| 69 |
</xsl:template> |
| 70 |
|
| 71 |
|
| 72 |
</xsl:stylesheet> |