| 1 |
<?xml version="1.0"?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:exsl="http://exslt.org/common" |
| 4 |
version="1.0" |
| 5 |
extension-element-prefixes="exsl"> |
| 6 |
|
| 7 |
<!--############################################################################ |
| 8 |
XSLT Stylesheet DocBook -> LaTeX |
| 9 |
############################################################################ --> |
| 10 |
|
| 11 |
<!-- All of this is taken from the DocBook Project chunker.xsl file, with some |
| 12 |
parts stripped (saxon, xalan support). We assume that exsl:document() |
| 13 |
is supported by any XSLT now. Moreover only text file output are supported |
| 14 |
here. --> |
| 15 |
|
| 16 |
<xsl:param name="chunker.output.method" select="'text'"/> |
| 17 |
<xsl:param name="chunker.output.encoding" select="'UTF-8'"/> |
| 18 |
<xsl:param name="chunker.output.indent" select="'no'"/> |
| 19 |
<xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/> |
| 20 |
<xsl:param name="chunker.output.standalone" select="'no'"/> |
| 21 |
<xsl:param name="chunker.output.doctype-public" select="''"/> |
| 22 |
<xsl:param name="chunker.output.doctype-system" select="''"/> |
| 23 |
<xsl:param name="chunker.output.media-type" select="''"/> |
| 24 |
<xsl:param name="chunker.output.cdata-section-elements" select="''"/> |
| 25 |
|
| 26 |
|
| 27 |
<xsl:template name="write.chunk"> |
| 28 |
<xsl:param name="filename" select="''"/> |
| 29 |
<xsl:param name="quiet" select="$output.quietly"/> |
| 30 |
|
| 31 |
<xsl:param name="method" select="$chunker.output.method"/> |
| 32 |
<xsl:param name="encoding" select="$chunker.output.encoding"/> |
| 33 |
<xsl:param name="indent" select="$chunker.output.indent"/> |
| 34 |
<xsl:param name="omit-xml-declaration" |
| 35 |
select="$chunker.output.omit-xml-declaration"/> |
| 36 |
<xsl:param name="standalone" select="$chunker.output.standalone"/> |
| 37 |
<xsl:param name="doctype-public" select="$chunker.output.doctype-public"/> |
| 38 |
<xsl:param name="doctype-system" select="$chunker.output.doctype-system"/> |
| 39 |
<xsl:param name="media-type" select="$chunker.output.media-type"/> |
| 40 |
<xsl:param name="cdata-section-elements" |
| 41 |
select="$chunker.output.cdata-section-elements"/> |
| 42 |
|
| 43 |
<xsl:param name="content"/> |
| 44 |
|
| 45 |
<xsl:if test="$quiet = 0"> |
| 46 |
<xsl:message> |
| 47 |
<xsl:text>Writing </xsl:text> |
| 48 |
<xsl:value-of select="$filename"/> |
| 49 |
<xsl:if test="name(.) != ''"> |
| 50 |
<xsl:text> for </xsl:text> |
| 51 |
<xsl:value-of select="name(.)"/> |
| 52 |
<xsl:if test="@id or @xml:id"> |
| 53 |
<xsl:text>(</xsl:text> |
| 54 |
<xsl:value-of select="(@id|@xml:id)[1]"/> |
| 55 |
<xsl:text>)</xsl:text> |
| 56 |
</xsl:if> |
| 57 |
</xsl:if> |
| 58 |
</xsl:message> |
| 59 |
</xsl:if> |
| 60 |
|
| 61 |
<xsl:choose> |
| 62 |
<xsl:when test="element-available('exsl:document')"> |
| 63 |
<xsl:choose> |
| 64 |
<!-- Handle the permutations ... --> |
| 65 |
<xsl:when test="$media-type != ''"> |
| 66 |
<xsl:choose> |
| 67 |
<xsl:when test="$doctype-public != '' and $doctype-system != ''"> |
| 68 |
<exsl:document href="{$filename}" |
| 69 |
method="{$method}" |
| 70 |
encoding="{$encoding}" |
| 71 |
indent="{$indent}" |
| 72 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 73 |
cdata-section-elements="{$cdata-section-elements}" |
| 74 |
media-type="{$media-type}" |
| 75 |
doctype-public="{$doctype-public}" |
| 76 |
doctype-system="{$doctype-system}" |
| 77 |
standalone="{$standalone}"> |
| 78 |
<xsl:copy-of select="$content"/> |
| 79 |
</exsl:document> |
| 80 |
</xsl:when> |
| 81 |
<xsl:when test="$doctype-public != '' and $doctype-system = ''"> |
| 82 |
<exsl:document href="{$filename}" |
| 83 |
method="{$method}" |
| 84 |
encoding="{$encoding}" |
| 85 |
indent="{$indent}" |
| 86 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 87 |
cdata-section-elements="{$cdata-section-elements}" |
| 88 |
media-type="{$media-type}" |
| 89 |
doctype-public="{$doctype-public}" |
| 90 |
standalone="{$standalone}"> |
| 91 |
<xsl:copy-of select="$content"/> |
| 92 |
</exsl:document> |
| 93 |
</xsl:when> |
| 94 |
<xsl:when test="$doctype-public = '' and $doctype-system != ''"> |
| 95 |
<exsl:document href="{$filename}" |
| 96 |
method="{$method}" |
| 97 |
encoding="{$encoding}" |
| 98 |
indent="{$indent}" |
| 99 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 100 |
cdata-section-elements="{$cdata-section-elements}" |
| 101 |
media-type="{$media-type}" |
| 102 |
doctype-system="{$doctype-system}" |
| 103 |
standalone="{$standalone}"> |
| 104 |
<xsl:copy-of select="$content"/> |
| 105 |
</exsl:document> |
| 106 |
</xsl:when> |
| 107 |
<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> --> |
| 108 |
<exsl:document href="{$filename}" |
| 109 |
method="{$method}" |
| 110 |
encoding="{$encoding}" |
| 111 |
indent="{$indent}" |
| 112 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 113 |
cdata-section-elements="{$cdata-section-elements}" |
| 114 |
media-type="{$media-type}" |
| 115 |
standalone="{$standalone}"> |
| 116 |
<xsl:copy-of select="$content"/> |
| 117 |
</exsl:document> |
| 118 |
</xsl:otherwise> |
| 119 |
</xsl:choose> |
| 120 |
</xsl:when> |
| 121 |
<xsl:otherwise> |
| 122 |
<xsl:choose> |
| 123 |
<xsl:when test="$doctype-public != '' and $doctype-system != ''"> |
| 124 |
<exsl:document href="{$filename}" |
| 125 |
method="{$method}" |
| 126 |
encoding="{$encoding}" |
| 127 |
indent="{$indent}" |
| 128 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 129 |
cdata-section-elements="{$cdata-section-elements}" |
| 130 |
doctype-public="{$doctype-public}" |
| 131 |
doctype-system="{$doctype-system}" |
| 132 |
standalone="{$standalone}"> |
| 133 |
<xsl:copy-of select="$content"/> |
| 134 |
</exsl:document> |
| 135 |
</xsl:when> |
| 136 |
<xsl:when test="$doctype-public != '' and $doctype-system = ''"> |
| 137 |
<exsl:document href="{$filename}" |
| 138 |
method="{$method}" |
| 139 |
encoding="{$encoding}" |
| 140 |
indent="{$indent}" |
| 141 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 142 |
cdata-section-elements="{$cdata-section-elements}" |
| 143 |
doctype-public="{$doctype-public}" |
| 144 |
standalone="{$standalone}"> |
| 145 |
<xsl:copy-of select="$content"/> |
| 146 |
</exsl:document> |
| 147 |
</xsl:when> |
| 148 |
<xsl:when test="$doctype-public = '' and $doctype-system != ''"> |
| 149 |
<exsl:document href="{$filename}" |
| 150 |
method="{$method}" |
| 151 |
encoding="{$encoding}" |
| 152 |
indent="{$indent}" |
| 153 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 154 |
cdata-section-elements="{$cdata-section-elements}" |
| 155 |
doctype-system="{$doctype-system}" |
| 156 |
standalone="{$standalone}"> |
| 157 |
<xsl:copy-of select="$content"/> |
| 158 |
</exsl:document> |
| 159 |
</xsl:when> |
| 160 |
<xsl:otherwise><!-- $doctype-public = '' and $doctype-system = ''"> --> |
| 161 |
<exsl:document href="{$filename}" |
| 162 |
method="{$method}" |
| 163 |
encoding="{$encoding}" |
| 164 |
indent="{$indent}" |
| 165 |
omit-xml-declaration="{$omit-xml-declaration}" |
| 166 |
cdata-section-elements="{$cdata-section-elements}" |
| 167 |
standalone="{$standalone}"> |
| 168 |
<xsl:copy-of select="$content"/> |
| 169 |
</exsl:document> |
| 170 |
</xsl:otherwise> |
| 171 |
</xsl:choose> |
| 172 |
</xsl:otherwise> |
| 173 |
</xsl:choose> |
| 174 |
</xsl:when> |
| 175 |
<xsl:otherwise> |
| 176 |
<!-- it doesn't matter since we won't be making chunks... --> |
| 177 |
<xsl:message terminate="yes"> |
| 178 |
<xsl:text>Can't make chunks with </xsl:text> |
| 179 |
<xsl:value-of select="system-property('xsl:vendor')"/> |
| 180 |
<xsl:text>'s processor.</xsl:text> |
| 181 |
</xsl:message> |
| 182 |
</xsl:otherwise> |
| 183 |
</xsl:choose> |
| 184 |
</xsl:template> |
| 185 |
|
| 186 |
|
| 187 |
<xsl:template name="write.text.chunk"> |
| 188 |
<xsl:param name="filename" select="''"/> |
| 189 |
<xsl:param name="quiet" select="0"/> |
| 190 |
<xsl:param name="method" select="'text'"/> |
| 191 |
<xsl:param name="encoding" select="$chunker.output.encoding"/> |
| 192 |
<xsl:param name="media-type" select="$chunker.output.media-type"/> |
| 193 |
<xsl:param name="content"/> |
| 194 |
|
| 195 |
<xsl:call-template name="write.chunk"> |
| 196 |
<xsl:with-param name="filename" select="$filename"/> |
| 197 |
<xsl:with-param name="quiet" select="$quiet"/> |
| 198 |
<xsl:with-param name="method" select="$method"/> |
| 199 |
<xsl:with-param name="encoding" select="$encoding"/> |
| 200 |
<xsl:with-param name="indent" select="'no'"/> |
| 201 |
<xsl:with-param name="omit-xml-declaration" select="'no'"/> |
| 202 |
<xsl:with-param name="standalone" select="'no'"/> |
| 203 |
<xsl:with-param name="doctype-public"/> |
| 204 |
<xsl:with-param name="doctype-system"/> |
| 205 |
<xsl:with-param name="media-type" select="$media-type"/> |
| 206 |
<xsl:with-param name="cdata-section-elements"/> |
| 207 |
<xsl:with-param name="content" select="$content"/> |
| 208 |
</xsl:call-template> |
| 209 |
</xsl:template> |
| 210 |
|
| 211 |
</xsl:stylesheet> |