[xsl] XSLT2 grouping over multiple documents

Subject: [xsl] XSLT2 grouping over multiple documents
From: "Thomas J. Sebestyen" <a9105535@xxxxxxxxxxxxxxxxx>
Date: Thu, 23 Jun 2005 01:49:57 +0200

I have a couple of xml-documents, all with the same structure:

<?xml version="1.0" encoding="UTF-8"?>
	<response for="js0" correct="correct">C</response>
	<response for="js1">A</response>
	<response for="js2" correct="correct">A</answer>
	<response for="db0" correct="correct">A</response>
	<response for="db1">B</response>

I use an xml-file to collect all this documents:

<?xml version="1.0" encoding="UTF-8"?>
	<a href="184855.xml" />
	<a href="190026.xml" />

I woul like to group all <response> by  @for over all documents and then
count how many from them has an @correct.
My solution is the following (which works for me):

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="2.0"
  <xsl:output method="html" indent="yes" encoding="iso-8859-1" />
  <xsl:template match="/alldocs">
    <xsl:variable name="alldocs">
      <xsl:for-each select="document(a/@href)">
        <xsl:copy-of select="/responses/response" />
        <xsl:for-each-group select="$alldocs/response" group-by="@for">
            <b><xsl:value-of select="current-grouping-key()" />=</b>
            <xsl:for-each-group select="current-group()"
              <xsl:value-of select="count(current-group())" />

Is there a better solution?
(for exmaple if I would like to sort the output by the number of


Current Thread