Subject: Re: [xsl] XSLT2, collection(), and xsl:key From: "James Cummings" <cummings.james@xxxxxxxxx> Date: Wed, 6 Feb 2008 12:21:33 +0000 |
On Feb 1, 2008 6:39 PM, Michael Kay <mike@xxxxxxxxxxxx> 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[@*[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][@*[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()[@type=current()])"/></td> </xsl:for-each> </tr> </xsl:for-each-group> </table> </xsl:for-each>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSLT2, collection(), and , Michael Kay | Thread | [xsl] understanding attributes and , Terry Ofner |
RE: [xsl] strip-spaces, Michael Kay | Date | RE: [xsl] WYSIWYG XSLT editor, Jim Garrison |
Month |