我需要将以下内容转换为 XSL 1.0 兼容性
<xsl:value-of select="count(distinct-values(/ChangeLog/ChangeSets//WorkItems//WorkItem/_ID))"/>
试过
<xsl:value-of select="count(/ChangeLog/ChangeSets//WorkItems//WorkItem/_ID[not(.=following::_ID)])"/>
这是示例 XML
<ChangeLog>
<ChangeSets>
<ChangeSet>
<ID>31</ID>
<Date>10/30/2012 2:05:59 AM</Date>
<Comment />
<User>XXX</User>
<WorkItems>
<WorkItem>
<_ID>2</_ID>
<_AreaID>1</_AreaID>
<_AuthorizedAs>XXX</_AuthorizedAs>
</WorkItem>
</WorkItems>
</ChangeSet>
<ChangeSet>
<ID>12</ID>
<Date>9/18/2012 7:30:43 AM</Date>
<Comment />
<User>XXX</User>
<WorkItems>
<WorkItem>
<_ID>1</_ID>
<_AreaID>1</_AreaID>
<_AuthorizedAs>XXX</_AuthorizedAs>
</WorkItem>
<WorkItem>
<_ID>2</_ID>
<_AreaID>1</_AreaID>
<_AuthorizedAs>XXX</_AuthorizedAs>
</WorkItem>
</WorkItems>
</ChangeSet>
<ChangeSet>
<ChangeSets>
</ChangeLog>
这是相同的 XSLT。请注意,这在 XSL 2.0 中。我需要将它转换为 XSL 1.0,因此问题。我已经单独更新了样式表版本以指向 XSL 1.0
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/ChangeLog">
<html>
<head>
<title>Release Notes Generated from TFS</title>
<style type="text/css">
.HeaderColumnStyle
{
width: 566px;
border: None;
}
.DataColumnStyle
{
border: none; width:auto;
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* ancient Opera */
white-space: -o-pre-wrap; /* newer Opera */
white-space: pre-wrap; /* Chrome; W3C standard */
word-wrap: break-word; /* IE */
}
.DescriptionDataColumnStyle
{
border: none;
width: 850px;
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* ancient Opera */
white-space: -o-pre-wrap; /* newer Opera */
white-space: pre-wrap; /* Chrome; W3C standard */
word-wrap: break-word; /* IE */
}
.style1
{
border-style: none;
border-color: inherit;
border-width: medium;
width: 60px;
}
</style>
</head>
<body>
<h1 align="center"> TFS Change Log Report</h1>
<table frame="box" border="3" style="width: 100%; border-bottom:#000080 outset;border-left:#000080 outset;border-top:#000080 outset;border-right:#000080 outset; text-align: left; vertical-align: middle;">
<tr>
<td class="HeaderColumnStyle">
<b>
<xsl:text>TFS Server : </xsl:text>
</b>
<xsl:apply-templates select="TFSServer/node()"/>
</td>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Project Name : </xsl:text>
</b>
<xsl:apply-templates select="TFSProjectName/node()"/>
</td>
</tr>
<tr>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Branch Location : </xsl:text>
</b>
<xsl:apply-templates select="TFSProjectBranchName/node()"/>
</td>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Report Produced By : </xsl:text>
</b>
<xsl:apply-templates select="ReportProducedBy/node()"/>
</td>
</tr>
<tr>
<td class="HeaderColumnStyle">
<b>
<xsl:text>From Changeset : </xsl:text>
</b>
<xsl:apply-templates select="FromChangeSet/node()"/>
</td>
<td class="HeaderColumnStyle">
<b>
<xsl:text>To Changeset : </xsl:text>
</b>
<xsl:apply-templates select="ToChangeSet/node()"/>
</td>
</tr>
<tr>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Total Number of Changesets : </xsl:text>
</b>
<xsl:value-of select="count(distinct-values(/ChangeLog//ChangeSet/ID))"/>
</td>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Total Number of Work Items : </xsl:text>
</b>
<xsl:value-of select="count(distinct-values(/ChangeLog/ChangeSets//WorkItems//WorkItem/_ID))"/>
</td>
</tr>
<tr>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Changesets with associated Work Items : </xsl:text>
</b>
<xsl:value-of select="count(/ChangeLog//ChangeSet[WorkItems/WorkItem/_ID[1] > 0])"/>
</td>
<td class="HeaderColumnStyle">
<b>
<xsl:text>Changesets without associated Work Items : </xsl:text>
</b>
<xsl:value-of select="count(distinct-values(/ChangeLog//ChangeSet/ID)) - count(/ChangeLog//ChangeSet[WorkItems/WorkItem/_ID[1] > 0])"/>
</td>
</tr>
<tr>
<td class="HeaderColumnStyle" colspan="2">
<b>
<xsl:text>Report Date : </xsl:text>
</b>
<xsl:apply-templates select="ReportDate/node()"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>