というわけで、Streetw☆さん、THREE-ONEさんのご協力により、なんとか完成しました。ありがとうございます。
もっとかっこいいコードに改造してくれる方、大募集!
<?xml version="1.0" encoding="UTF-16" standalone="yes" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output
method="xml" version="1.0" encoding="UTF-16" standalone="no" indent="yes" media-type="application/xhtml+xml"
doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
<xsl:template match="/">
<html>
<head>
<title>プロダクトキー一覧</title>
<style type="text/css">
<![CDATA[
table
{
border-collapse: collapse;
}
th, td
{
border: thin solid black;
padding: 0.5em;
}
]]>
</style>
</head>
<body>
<xsl:apply-templates select="YourKey"/>
</body>
</html>
</xsl:template>
<xsl:template match="YourKey">
<table summary="一覧">
<thead>
<tr>
<th scope="col">Product</th>
<th scope="col">Key</th>
<th scope="col">Type</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="Product_Key">
<xsl:sort select="@Name"/>
</xsl:apply-templates>
</tbody>
</table>
</xsl:template>
<xsl:template match="Product_Key">
<xsl:variable name="thisName" select="@Name"/>
<xsl:variable name="thisKey" select="Key/text()"/>
<xsl:variable name="sameNamesBefore" select="count(preceding-sibling::Product_Key[ @Name = $thisName ])"/>
<xsl:variable name="sameNamesAfter" select="count(following-sibling::Product_Key[ @Name = $thisName ])"/>
<xsl:variable name="sameNameAndKeysBefore" select="count(preceding-sibling::Product_Key[ Key/text() = $thisKey and @Name = $thisName ])"/>
<xsl:variable name="sameNameAndKeysAfter" select="count(following-sibling::Product_Key[ Key/text() = $thisKey and @Name = $thisName ])"/>
<xsl:if test="$sameNameAndKeysBefore = 0">
<tr>
<xsl:if test="$sameNamesBefore = 0">
<td>
<xsl:if test="( $sameNamesAfter - $sameNameAndKeysAfter ) != 0">
<xsl:attribute name="rowspan"><xsl:value-of select="$sameNamesAfter - $sameNameAndKeysAfter + 1"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="@Name"/>
</td>
</xsl:if>
<td>
<xsl:value-of select="Key" disable-output-escaping="yes"/>
</td>
<td>
<xsl:value-of select="Key/@Type"/>
</td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>