On Feb 1, 2008 6:39 PM, Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:
OK, I misunderstood. I thought that's what you meant by doing it manually,
and that that wasn't what you wanted to do.
To make it data-driven like this, you get rid of the outer
xsl:for-each-group and replace it with an <xsl:for-each select="table">, and
then you do something like
<xsl:variable name="table" select="."/>
<xsl:variable name="pop"
select="collection('...')//*[name()=$table/@element[(_at_)*[name()=$table/@att]]]
"/>
and then
<xsl:variable name="types"
select="distinct-values($pop/@*[name()=$table/@att)"/>
Just for posterity (because I'm bound to forget...), to check I'm
doing it right if anyone cares to comment what I ended up doing was
something along the lines of:
<xsl:variable name="docs" select="collection('../../working/xml/files.xml')"/>
<xsl:variable name="tables">
<table element="placeName" att="type"/>
<table element="persName" att="type"/>
<!-- And many more etc -->
</xsl:variable>
<xsl:for-each select="$tables/tei:table">
<xsl:variable name="table" select="."/>
<xsl:variable name="pop"
select="$docs//*[name()=$table/@element][(_at_)*[name()=$table/@att]]"/>
<xsl:variable name="types"
select="distinct-values($pop/@*[name()=$table/@att])"/>
<table>
<tr>
<td>document</td>
<xsl:variable name="types"
select="distinct-values($pop/@*[name()=$table/@att])"/>
<xsl:for-each select="$types">
<td><xsl:value-of select="."/></td>
</xsl:for-each>
</tr>
<xsl:for-each-group select="$pop"
group-by="ancestor-or-self::tei:text">
<tr>
<td><xsl:value-of
select="ancestor-or-self::tei:text//tei:date[1]/substring-before(@when,
'-')"/></td>
<xsl:for-each select="$types">
<td><xsl:value-of
select="count(current-group()[(_at_)type=current()])"/></td>
</xsl:for-each>
</tr>
</xsl:for-each-group>
</table>
</xsl:for-each>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--