[xsl] Contexts that are atomic values

Subject: [xsl] Contexts that are atomic values
From: Michel Charpentier <charpov@xxxxxxx>
Date: Tue, 21 Jun 2005 18:12:58 -0400
Hi,

I need to organize a list of items by genre (@type) so that all the items of a given genre end up in the same file. The following code works:

<xsl:template match="items">
<xsl:for-each select="distinct-values(item/@type)">
<xsl:result-document href="html/{.}.html">
<xsl:apply-templates select="document('music.xml')/ key('by-type',current())"/>
</xsl:result-document>
</xsl:for-each>
</xsl:template>


What bothers me is that I need the 'document("music.xml")' part ('music.xml' is the xml file I'm processing). If I don't have it, Saxon (8B) complains that it cannot process nodes from an atomic context (the string I'm currently processing, I suppose). Same thing if I use //item[@type = current()] instead of a call to key(). So, whether I use key() or not, I still need to start from 'document ("music.xml")' and I don't like it.

Is this behavior normal? Is there a workaround that does not require me to refer to 'music.xml' explicitly?

Thanks,

MC
--
2p3p[dl!d2+s!%0=@l!l^!<#]s#[s/0ds^]s@[p]s&[ddvs^3s!l#x0<&2+l.x]ds.x

Current Thread