| 1 |
<?xml version='1.0' encoding="iso-8859-1"?> |
| 2 |
<!DOCTYPE xsl:stylesheet [ |
| 3 |
<!ENTITY t1 "Ͱt"> |
| 4 |
<!ENTITY t2 "ͱt"> |
| 5 |
<!ENTITY u1 "Ͱu"> |
| 6 |
<!ENTITY u2 "ͱu"> |
| 7 |
<!ENTITY v1 "Ͱu"> |
| 8 |
<!ENTITY v2 "ͱu"> |
| 9 |
<!ENTITY h1 "Ͱh"> |
| 10 |
<!ENTITY h2 "ͱh"> |
| 11 |
<!ENTITY l1 "Ͱl"> |
| 12 |
<!ENTITY l2 "ͱl"> |
| 13 |
]> |
| 14 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 15 |
xmlns:m="http://www.w3.org/1998/Math/MathML" |
| 16 |
version='1.0'> |
| 17 |
|
| 18 |
<!--############################################################################ |
| 19 |
XSLT Stylesheet DocBook -> LaTeX |
| 20 |
############################################################################ --> |
| 21 |
|
| 22 |
<!-- These templates boost the text processing but needs some post-parsing |
| 23 |
to escape the TeX characters and do the encoding. --> |
| 24 |
|
| 25 |
<!-- use Reserved Unicode characters as delimiters --> |
| 26 |
<xsl:template name="scape" > |
| 27 |
<xsl:param name="string"/> |
| 28 |
<xsl:text>&t1;</xsl:text> |
| 29 |
<xsl:value-of select="$string"/> |
| 30 |
<xsl:text>&t2;</xsl:text> |
| 31 |
</xsl:template> |
| 32 |
|
| 33 |
<!-- tag the text for post-processing --> |
| 34 |
<xsl:template match="text()"> |
| 35 |
<xsl:text>&t1;</xsl:text> |
| 36 |
<xsl:value-of select="."/> |
| 37 |
<xsl:text>&t2;</xsl:text> |
| 38 |
</xsl:template> |
| 39 |
|
| 40 |
<xsl:template match="text()" mode="latex.programlisting"> |
| 41 |
<xsl:param name="probe" select="0"/> |
| 42 |
<xsl:if test="$probe = 0"> |
| 43 |
<xsl:text>&v1;</xsl:text> |
| 44 |
<xsl:value-of select="."/> |
| 45 |
<xsl:text>&v2;</xsl:text> |
| 46 |
</xsl:if> |
| 47 |
</xsl:template> |
| 48 |
|
| 49 |
<xsl:template match="text()" mode="latex.verbatim"> |
| 50 |
<xsl:text>&v1;</xsl:text> |
| 51 |
<xsl:value-of select="."/> |
| 52 |
<xsl:text>&v2;</xsl:text> |
| 53 |
</xsl:template> |
| 54 |
|
| 55 |
<!-- specific handling depending on the context --> |
| 56 |
<xsl:template match="text()[ancestor::ulink]"> |
| 57 |
<!-- LaTeX chars are scaped. Each / except the :// is mapped to a /\- --> |
| 58 |
<xsl:apply-templates select="." mode="slash.hyphen"/> |
| 59 |
</xsl:template> |
| 60 |
|
| 61 |
<!-- replace some text in a string *as if* the string is already escaped. |
| 62 |
Here it ends to inserting raw text between tags. --> |
| 63 |
<xsl:template name="scape-replace" > |
| 64 |
<xsl:param name="string"/> |
| 65 |
<xsl:param name="from"/> |
| 66 |
<xsl:param name="to"/> |
| 67 |
<xsl:call-template name="string-replace"> |
| 68 |
<xsl:with-param name="string" select="$string"/> |
| 69 |
<xsl:with-param name="from" select="$from"/> |
| 70 |
<xsl:with-param name="to" select="concat('&t2;',$to,'&t1;')"/> |
| 71 |
</xsl:call-template> |
| 72 |
</xsl:template> |
| 73 |
|
| 74 |
<!-- just ask for encoding --> |
| 75 |
<xsl:template name="scape-encode" > |
| 76 |
<xsl:param name="string"/> |
| 77 |
<xsl:text>&u1;</xsl:text> |
| 78 |
<xsl:value-of select="$string"/> |
| 79 |
<xsl:text>&u2;</xsl:text> |
| 80 |
</xsl:template> |
| 81 |
|
| 82 |
<!-- Even ids (id|xml:id) need to be encoded to be valid latex labels --> |
| 83 |
<xsl:template match="*" mode="id-encode" name="id-encode" > |
| 84 |
<xsl:param name="string" select="(@id|@xml:id)[1]"/> |
| 85 |
<xsl:text>&l1;</xsl:text> |
| 86 |
<xsl:value-of select="$string"/> |
| 87 |
<xsl:text>&l2;</xsl:text> |
| 88 |
</xsl:template> |
| 89 |
|
| 90 |
<!-- ask for hyphenating --> |
| 91 |
<xsl:template name="hyphen-encode" > |
| 92 |
<xsl:param name="string"/> |
| 93 |
<xsl:text>&h1;</xsl:text> |
| 94 |
<xsl:value-of select="$string"/> |
| 95 |
<xsl:text>&h2;</xsl:text> |
| 96 |
</xsl:template> |
| 97 |
|
| 98 |
<!-- specific behaviour for MML --> |
| 99 |
<xsl:template match="m:*/text()"> |
| 100 |
<xsl:call-template name="mmltext"/> |
| 101 |
</xsl:template> |
| 102 |
|
| 103 |
<xsl:template name="normalize-scape" > |
| 104 |
<xsl:param name="string"/> |
| 105 |
<xsl:call-template name="scape"> |
| 106 |
<xsl:with-param name="string"> |
| 107 |
<xsl:value-of select="normalize-space($string)"/> |
| 108 |
</xsl:with-param> |
| 109 |
</xsl:call-template> |
| 110 |
</xsl:template> |
| 111 |
|
| 112 |
</xsl:stylesheet> |