|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT2, collection(), and xsl:key
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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






