我是XSLT(v1.0)的新手,我无法使用XSLT将复杂的XHTML表转换为LaTeX.
当我说复杂的表时,我的意思是具有不同列数的行的表.换句话说,td
用colspan
.
即(xhtml表)
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="68" colspan="3"> <p>Values</p> </td>
</tr>
<tr>
<td valign="top" width="68"> <p>95</p> </td>
<td valign="top" width="68"> <p>169</p> <p> </p> </td>
<td valign="top" width="68"> <p>180</p> <p> </p> </td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我在XSL文件中做的是:
<xsl:template match="xhtml:table[@border='1']">
<xsl:text>\begin{center}</xsl:text>
<xsl:text>\begin{tabular}{</xsl:text>
<xsl:for-each select="xhtml:tr[1]/*">
<xsl:text>c</xsl:text>
<xsl:if test="position() = last()">
<xsl:text>} </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>\toprule </xsl:text>
<xsl:for-each select="xhtml:tr">
<xsl:if test="position() != 1">
<xsl:text>\midrule </xsl:text>
</xsl:if>
<xsl:if test="position() = 2">
<xsl:text>\midrule </xsl:text>
</xsl:if>
<xsl:for-each select="xhtml:td|xhtml:th">
<xsl:if test="name() = 'th'">{\bf </xsl:if>
<xsl:apply-templates /> …
Run Code Online (Sandbox Code Playgroud)