这是我的 xml 输入
<issues>
<issue status="open" type="Bug">
<fix_versions>
<fix_version>6.14.0</fix_version>
<fix_version>6.13.0</fix_version>
<fix_version>6.12.0</fix_version>
</fix_versions>
<title>issue1</title>
<description>Description</description>
</issue>
<issue status="open" type="Feature">
<fix_versions>
<fix_version>6.13.0</fix_version>
</fix_versions>
<title>issue2</title>
<description>Description</description>
</issue>
<issue status="open" type="Improvement">
<fix_versions>
<fix_version>6.14.0</fix_version>
</fix_versions>
<title>issue3</title>
<description>Description</description>
</issue>
...
</issues>
这是我的 xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="versions" match="fix_version" use="."/>
<xsl:key name="type" match="@type" use="../*/fix_version"/>
<xsl:template match="fix_version[generate-id()=generate-id(key('versions',.)[1])]">
<div class="version">
<a><xsl:value-of select="."/></a>
<xsl:value-of select="../../@type"/>
<div class="issues">
<xsl:for-each select="key('type',.)">
<div class="{..}">
<a href="{../title}"><xsl:value-of select="../title"/></a>
</div>
</xsl:for-each>
</div>
</div>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
我想要这样的输出:
<div class="version">
<a>6.14.0</a>
<div class="issues">
<div class="Bugs">
<a href="issue1">issue1</a>
<a href="issue7">issue7</a>
<a href="issue2">issue12</a>
<a href="issue17">issue17</a>
</div>
<div class="Improvements">
<a href="issue3">issue3</a>
<a href="issue9">issue9</a>
</div>
</div>
</div>
<div class="version">
<a>6.13.0</a>
<div class="issues">
<div class="Bug">
<a href="issue1">issue1</a>
<a href="issue11">issue11</a>
</div>
<div class="Feature">
<a href="issue2">issue2</a>
</div>
</div>
</div>
<div class="version">
<a>6.12.0</a>
<div class="issues">
<div class="Bug">
<a href="issue1">issue1</a>
</div>
</div>
</div>
但我有这样的输出:
<div class="version">
<a>6.14.0</a>
<div class="issues">
<div class="Bugs">
<a href="issue1">issue1</a>
</div>
<div class="Bugs">
<a href="issue7">issue7</a>
</div>
<div class="Bugs">
<a href="issue2">issue12</a>
</div>
<div class="Bugs">
<a href="issue17">issue17</a>
</div>
<div class="Improvements">
<a href="issue3">issue3</a>
</div>
<div class="Improvements">
<a href="issue9">issue9</a>
</div>
</div>
</div>
<div class="version">
<a>6.13.0</a>
<div class="issues">
<div class="Bug">
<a href="issue1">issue1</a>
</div>
<div class="Bug">
<a href="issue11">issue11</a>
</div>
<div class="Feature">
<a href="issue2">issue2</a>
</div>
</div>
</div>
<div class="version">
<a>6.12.0</a>
<div class="issues">
<div class="Bug">
<a href="issue1">issue1</a>
</div>
</div>
</div>
如您所见,问题没有分组在名为“错误”、“改进”或“功能”的容器中——但这就是我想要的。我试过这样的东西
但无论我尝试什么 - 都没有奏效。我真的没有计划如何将它们分组。