Просто для удовольствия, эта таблица стилей:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="vMaxLengthIds">
<xsl:for-each select="/table/tr[1]/*">
<xsl:variable name="vPosition" select="position()"/>
<xsl:for-each select="/table/tr/*[$vPosition]">
<xsl:sort select="string-length(.)" data-type="number" />
<xsl:if test="position() = last()">
<xsl:value-of select="concat('|',generate-id(),'|')" />
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="vMaxLength"
select="/table/tr/*[contains(
$vMaxLengthIds,
concat('|',generate-id(),'|'))]"/>
<xsl:variable name="vPaddingMask"
select="' '"/>
<xsl:template match="tr">
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="td">
<xsl:apply-templates/>
<xsl:text> | </xsl:text>
</xsl:template>
<xsl:template match="th">
<xsl:apply-templates/>
<xsl:text> + </xsl:text>
</xsl:template>
<xsl:template match="tr/*/text()">
<xsl:variable name="vPosition"
select="count(../preceding-sibling::*)"/>
<xsl:value-of
select="concat(
.,
substring(
$vPaddingMask,
1,
string-length(
$vMaxLength[count(preceding-sibling::*)
= $vPosition])
- string-length()))"/>
</xsl:template>
</xsl:stylesheet>
С этим входом:
<table>
<tr>
<th>Day</th>
<th>Month</th>
<th>Year</th>
</tr>
<tr>
<td>1</td>
<td>January</td>
<td>2011</td>
</tr>
<tr>
<td>31</td>
<td>June</td>
<td>2011</td>
</tr>
<tr>
<td>11</td>
<td>February</td>
<td>2011</td>
</tr>
</table>
Выход:
Day + Month + Year +
1 | January | 2011 |
31 | June | 2011 |
11 | February | 2011 |