不。当前上下文无法知道哪些节点是“下一个”或“上一个”。
这是因为,例如,当应用模板时,其机制如下:
<xsl:apply-templates select="*" /><!-- select 3 nodes (a,b,c) -->current()节点被定义,并且position()被定义,但除此之外,模板不知道执行流程。您可以使用following::sibling或preceding::siblingXPath 轴,但这与了解接下来要处理的节点不同
编辑
上面的解释试图回答所提出的问题,但OP的意思有所不同。它仅涉及分组/输出唯一节点。
根据 OP 的要求,这里快速演示了如何使用 XPath 轴实现分组。
XML(项目已预先排序):
<items>
  <item type="a"></item>
  <item type="a"></item>
  <item type="a"></item>
  <item type="a"></item>
  <item type="b"></item>
  <item type="e"></item>
</items>
XSLT
<xsl:stylesheet 
  version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
  <xsl:template match="/items">
    <!-- copy the root element -->
    <xsl:copy>
      <!-- select those items that differ from any of their predecessors -->
      <xsl:apply-templates select="
        item[
          not(@type = preceding-sibling::item/@type)
        ]
      " />
    </xsl:copy>
  </xsl:template>
  <xsl:template match="item">
    <!-- copy the item to the output -->
    <xsl:copy-of select="." />
  </xsl:template>
</xsl:stylesheet>
输出:
<items>
  <item type="a"></item>
  <item type="b"></item>
  <item type="e"></item>
</items>