| 1 |
<?xml version="1.0"?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:m="http://www.w3.org/1998/Math/MathML" |
| 4 |
version="1.0"> |
| 5 |
|
| 6 |
<!-- This stylesheet builds the latex data just for a portion of the input |
| 7 |
XML document, the portion being identified by its identifier (@id) |
| 8 |
through the '$extractid' parameter. |
| 9 |
|
| 10 |
No need to <xsl:import> the main dblatex XSL stylesheet, since dblatex |
| 11 |
does it for you. |
| 12 |
--> |
| 13 |
|
| 14 |
<xsl:param name="extractid"/> |
| 15 |
|
| 16 |
<xsl:template match="/"> |
| 17 |
<xsl:apply-templates mode="extract"/> |
| 18 |
</xsl:template> |
| 19 |
|
| 20 |
<xsl:template match="*" mode="extract"> |
| 21 |
<xsl:choose> |
| 22 |
<xsl:when test="@id=$extractid"> |
| 23 |
<xsl:message> |
| 24 |
<xsl:text>Found '</xsl:text> |
| 25 |
<xsl:value-of select="local-name(.)"/> |
| 26 |
<xsl:text>' with id='</xsl:text> |
| 27 |
<xsl:value-of select="@id"/> |
| 28 |
<xsl:text>'</xsl:text> |
| 29 |
</xsl:message> |
| 30 |
<xsl:variable name="texdata"> |
| 31 |
<!-- do the normal stuff --> |
| 32 |
<xsl:apply-templates select="."/> |
| 33 |
</xsl:variable> |
| 34 |
|
| 35 |
<!-- output the partial object as whole document --> |
| 36 |
<xsl:call-template name="wrap.tex"> |
| 37 |
<xsl:with-param name="content" select="$texdata"/> |
| 38 |
</xsl:call-template> |
| 39 |
|
| 40 |
<!-- building an intermediate file instead would be: |
| 41 |
<xsl:call-template name="build.texfile"> |
| 42 |
<xsl:with-param name="content" select="$texdata"/> |
| 43 |
<xsl:with-param name="id" select="@id"/> |
| 44 |
</xsl:call-template> |
| 45 |
|
| 46 |
--> |
| 47 |
</xsl:when> |
| 48 |
<xsl:otherwise> |
| 49 |
<xsl:apply-templates mode="extract"/> |
| 50 |
</xsl:otherwise> |
| 51 |
</xsl:choose> |
| 52 |
</xsl:template> |
| 53 |
|
| 54 |
<xsl:template match="text()" mode="extract"/> |
| 55 |
|
| 56 |
<!-- Content of the tex file --> |
| 57 |
<xsl:template name="wrap.tex"> |
| 58 |
<xsl:param name="content"/> |
| 59 |
|
| 60 |
<xsl:text>\documentclass</xsl:text> |
| 61 |
<xsl:if test="$latex.class.options!=''"> |
| 62 |
<xsl:text>[</xsl:text> |
| 63 |
<xsl:value-of select="$latex.class.options"/> |
| 64 |
<xsl:text>]</xsl:text> |
| 65 |
</xsl:if> |
| 66 |
<xsl:text>{article} </xsl:text> |
| 67 |
<xsl:text>\usepackage[T1]{fontenc} </xsl:text> |
| 68 |
<xsl:text>\usepackage[latin1]{inputenc} </xsl:text> |
| 69 |
|
| 70 |
<xsl:call-template name="font.setup"/> |
| 71 |
<xsl:text>\usepackage[hyperlink]{</xsl:text> |
| 72 |
<xsl:value-of select="$latex.style"/> |
| 73 |
<xsl:text>} </xsl:text> |
| 74 |
|
| 75 |
<xsl:call-template name="citation.setup"/> |
| 76 |
<xsl:call-template name="lang.setup"/> |
| 77 |
|
| 78 |
<xsl:text>\pagestyle{empty} </xsl:text> |
| 79 |
|
| 80 |
<xsl:text>\begin{document} </xsl:text> |
| 81 |
<xsl:value-of select="$content"/> |
| 82 |
<xsl:text>\end{document} </xsl:text> |
| 83 |
</xsl:template> |
| 84 |
|
| 85 |
<!-- Build a latex file --> |
| 86 |
<!-- In the case one wants to build an intermediate file --> |
| 87 |
<xsl:template name="build.texfile"> |
| 88 |
<xsl:param name="content"/> |
| 89 |
<xsl:param name="id"/> |
| 90 |
<xsl:call-template name="write.text.chunk"> |
| 91 |
<xsl:with-param name="filename"> |
| 92 |
<xsl:text>tex_</xsl:text> |
| 93 |
<xsl:value-of select="$id"/> |
| 94 |
<xsl:text>.rtex</xsl:text> |
| 95 |
</xsl:with-param> |
| 96 |
<xsl:with-param name="method" select="'text'"/> |
| 97 |
<xsl:with-param name="content"> |
| 98 |
<xsl:call-template name="wrap.tex"> |
| 99 |
<xsl:with-param name="content" select="$content"/> |
| 100 |
</xsl:call-template> |
| 101 |
</xsl:with-param> |
| 102 |
<xsl:with-param name="encoding" select="$chunker.output.encoding"/> |
| 103 |
</xsl:call-template> |
| 104 |
</xsl:template> |
| 105 |
|
| 106 |
</xsl:stylesheet> |